Monday, June 12, 2017

How to apply Count on multiple distinct columns and use Having clause

If you group by these columns then you already only get those unique records and then you can use count(*) to get how many duplicates you have.
select A,B,C, count(*) 
from table_name 
group by A,B,C 
HAVING count(*) > 1