How To Find Duplicate Records in SQL


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