Skip to content
Advertisement

Finding duplicate values in multiple colums in a SQL table and count

I have the following table structure:

I use the following command to display the duplicates and the counts:

This command gives me a count of 2. I would like to know how the second line could also be counted as a dublicate.

Advertisement

Answer

You need the scalar functions MIN() and MAX() to get the 3 integer values of each row in ascending order, so that you can create a unique triplet to group by:

See the demo.

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