Some pseudo-code to help you in the right direction: Assuming Set A is your first set, Select a set of records from Set A which have more than one row. Call that Set B. Return all the records from Set A where the key is in Set B. This should be returning only the duplicate rows. You could accomplish this using a CTE or a subquery, but other ways are possible.