select u.c_name,case when ur.c_role_id=73 then 'A類型' else 'B類型' end as roletype, case when u.c_online_status=1 then'線上' else '不線上' end as onlinestatus... ...
select u.c_name,case when ur.c_role_id=73 then 'A類型' else 'B類型' end as roletype, case when u.c_online_status=1 then'線上' else '不線上' end as onlinestatus, t.* from (select ai.c_signed_user_id, count(1) as rcvEvtCount,sum(case when c_finished_date is null then 1 else 0 end) as unPrcEvtCount from t_wf_activity_instance ai group by ai.c_signed_user_id) as t join t_pmi_user u on u.c_id=t.c_signed_user_id join t_pmi_user_in_role ur on ur.c_user_id=u.c_id where ur.c_role_id in('73','74') and u.c_db_status=0