3

我有一个分组查询,并想根据 count(*) 过滤它

我可以在没有子查询的情况下做到这一点吗?

这是我目前拥有的:

select * 
  from (select ID,
               count(*) cnt
          from name
      group by ID)
 where cnt > 1;
4

1 回答 1

16

您正在寻找的是HAVING条款:

select ID, count(*) cnt
from name
group by ID
having count(*) > 1;
于 2010-05-25T17:34:50.237 回答