学习关于聚合FUNCTION(count(*|fieldname))

来源:互联网 发布:mac权限 编辑:程序博客网 时间:2024/05/06 23:07
 -----------------结果集为刚好分组后每组中记录数为3个
select * from b t  
where (select count(*) from b where a = t.a and b > t.b) <3
 and exists(select count(*) from b where a=t.a group by a having count(*)>=3)
go
----------------结晶集为分组后每组中记录数为》=3个
select *
from b t
where exists(select count(*) from b where a=t.a group by a having count(*)>=3)
原创粉丝点击