19 April 2017

How To Find Duplicate Record in SQL

Whenever I need to delete duplicate records in database, I try to find them first and identify the number of times the same row occurs.

Here's a simple way to find them:

SELECT Name, Age, COUNT(*) AS NoOfDuplicateRecords
FROM Table_Name
GROUP BY Name, Age
HAVING COUNT(*) > 1

No comments:

Post a Comment