I found a lot of answers on how to find duplicates, including a PK column or with no focus on it, like this:
If you have a table called T1 and the columns are c1, c2 and c3, then this query will show you duplicate values.
SELECT C1, C2, C3, count(*)as DupCount
from T1
GROUP BY C1, C2, C3
HAVING COUNT(*) > 1
But a more general requirement would be to get the identifier of all duplicates having equal values c1, c2, c3.
So, I need to do something that does not work, because the identifier must be aggregated:
SELECT ID
from T1
GROUP BY C1, C2, C3
HAVING COUNT(*) <> 1
(The identifier of all duplicates should be different, but the columns should be equal)
Edit :
Thanks to everyone. I always wonder how quickly people give great answers to Stackoverflow!
source
share