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

count, distinct, indexing, oracle, sql

Solution

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

Problem

I would like to do something like this , but getting an error please suggest some good methods? ``` select A,B,C, count(Distinct A,B,C) from table_name group by A,B,C having count(Distinct A,B,C) > 1 ``` Basically i have an index on the columns(A,B,C), and some rows doesnt have this unique combination set, So I'm trying a query similar to identify the rows which disobeys the unique constraint. PLease let me know if there is a best way

Original source