How To Find Duplicate Records in SQL

September 05, 2012 , , 0 Comments


Following code is useful to select duplicate records in SQL.

For Example : Table TABLE_NAME has three columns COL1, COL2, COL3 and COL4

Now you can use below script to select duplicate records from table TABLE_NAME

SELECT count(1) TOTAL_RECORDS, * FROM TABLE_NAME group by COL1, COL2, COL3, COL4

having COUNT(1) > 1

Prakash Hari Sharma
I'm a software developer and Java enthusiast. I like clean and modular code, enjoy Agile projects and have a passion for trying out new things. I try to learn and teach every day, and occasionally I'm even able to blog about it. :)