22,206
社区成员
发帖
与我相关
我的任务
分享
select czy ,COUNT(czzl) num from 表名称 group by czy
--漏了条件,补上
select czy,count(czy) as counts from (
select czy,czzl,COUNT(distinct czzl) as numbers from cte
group by czy,czzl
) t
group by czy
having count(czy)>5
--try this
select czy,count(czy) as counts from (
select czy,czzl,COUNT(distinct czzl) as numbers from cte
group by czy,czzl
) t
group by czy
SELECT COUNT(DISTINCT czy)
FROM tableA AS a
WHERE EXISTS ( SELECT 1
FROM tableA
WHERE czy = a.czy
HAVING COUNT(DISTINCT czzl) >= 5 )