I have a grouped query, and would like to filter it based on count(*)
Can I do this without a subquery?
This is what I have currently:
select *
from (select ID,
count(*) cnt
from name
group by ID)
where cnt > 1;
I have a grouped query, and would like to filter it based on count(*)
Can I do this without a subquery?
This is what I have currently:
select *
from (select ID,
count(*) cnt
from name
group by ID)
where cnt > 1;
what you are looking for is the HAVING
clause:
select ID, count(*) cnt
from name
group by ID
having count(*) > 1;