Skip to content
Advertisement

List All Rows Containing Duplicates SQL

I want to List All Rows Containing Duplicates by a name in the table for instance, name = TestName or TestName1 or Test name 2.. but also want to know what else is attached to them..

I have done this query.

I have found duplicated records but you’re interested in getting all the information attached to them, however this is all on one table..

I have tried to do this..

select * from my_table a join ( select firstname, lastname from my_table group by firstname, lastname having count(*) > 1 ) b on a.firstname = b.firstname and a.lastname = b.lastname

but this is if the data was on 2 separate tables?

Advertisement

Answer

You can use window functions:

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