查看: 1705|回复: 0

[SQLServer] groud by 多表关联

发表于 2017-9-14 08:00:01
太阳http代理AD
  1. select u.c_name,case when ur.c_role_id=73 then 'A类型' else 'B类型' end as roletype,
  2. case when u.c_online_status=1 then'在线' else '不在线' end as onlinestatus, t.* from
  3. (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
  4. from t_wf_activity_instance ai
  5. group by ai.c_signed_user_id) as t join t_pmi_user u on u.c_id=t.c_signed_user_id
  6. join t_pmi_user_in_role ur on ur.c_user_id=u.c_id
  7. where ur.c_role_id in('73','74') and u.c_db_status=0
复制代码



太阳http代理AD
回复

使用道具 举报