Skip to content
Advertisement

Finding Duplicates in SQL

I’m trying to find duplicates in a non-traditional scenario:

Sample Table:

I only want to retain one of these rows, as these ids show a connection to each other. What is the most elegant way to filter out the second row?

Advertisement

Answer

To find the dups, but only retain those where id1 is smaller than id2.

An EXISTS can be used for that.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement