过滤oracle中的count(*)

chr*_*ris 2 sql oracle aggregate-functions

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

没有子查询我可以这样做吗?

这就是我目前所拥有的:

select * 
  from (select ID,
               count(*) cnt
          from name
      group by ID)
 where cnt > 1;
Run Code Online (Sandbox Code Playgroud)

Eri*_*lje 13

您正在寻找的是HAVING条款:

select ID, count(*) cnt
from name
group by ID
having count(*) > 1;
Run Code Online (Sandbox Code Playgroud)

  • @chris - 小马很好,但是你真的可以相信一只带着彩虹的麒麟吗?我想不是 :) (2认同)