sql中的having表示对查询结果之后的过滤

sql中的having表示对查询结果之后的过滤,下面的例子是对group by之后的结果进行过滤

 

SELECT DISTINCT(dz_code) from zb_tech_info_collect_unit
where
szjd = '20212'
and ssfd_id in (select dept_id from sys_dept where (dept_id='J00001' or ancestors like CONCAT('0', ',', 'J00001', '%')))
group by dz_code
having count(1) >1

 

posted @ 2021-11-23 09:45  northli  阅读(227)  评论(0编辑  收藏  举报