mysql分组查询group by 与having

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hai7425/article/details/83379661
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;

猜你喜欢

转载自blog.csdn.net/hai7425/article/details/83379661