mysql分组查询group by 与having

xiaoxiao2025-07-16  11

select a.run_id,a.user_id,b.dept_id, count(*) as jishu from flow_run_prcs as a,user as b where a.USER_ID=b.user_id group by run_id,user_id,dept_id having count(*)>1; select a.run_id,b.dept_id,count(*) as jishu from flow_run_prcs as a,user as b where a.USER_ID=b.user_id group by run_id,dept_id having count(*)>1; select b.dept_id,count(run_id) as jishu from flow_run_prcs as a,user as b where a.USER_ID=b.user_id group by dept_id having count(dept_id)>1;

 

转载请注明原文地址: https://www.6miu.com/read-5033181.html

最新回复(0)