case when 条件 then 操作 else 操作 end
举例:
select t.*,(select count(*) mobcount from mob_bas_role_agent a where a.role_id=t.role_id) clientcount,(select count(*) from mob_bas_role_agent d where d.role_id=t.role_id and d.send_flag=1 ) clientsendcount,
case when t.role_type<1 then (select count(*) from mob_mcc_stat_fit b where b.role_id=t.role_id) else (select count(*) from mob_mcc_stat_stable c where c.role_id=t.role_id) end finishClientCount
from (select re.*, rownum rownum_
from (select r.role_id, r.role_name, r.role_type, r.flag
from mob_bas_role r
where r.username ='username'
and r.flag != 9
order by r.indate desc) re) t
where t.rownum_ between 1 and 5