How to find the duplicate records in a table?
Query:
Simple Table
SELECT c1, c2, ... ,cn, count(*)
FROM TableName
GROUP BY c1, c2,..., cn
HAVING count(*) > 1;
Table with Joins:
SELECT c1, c2, ... ,cn, count(*)
FROM TableName1
INNER JOIN TableName2 on TableName1.ColName=TableName2.ColName
GROUP BY c1, c2,..., cn HAVING count(*) > 1;
Query:
Simple Table
SELECT c1, c2, ... ,cn, count(*)
FROM TableName
GROUP BY c1, c2,..., cn
HAVING count(*) > 1;
Table with Joins:
SELECT c1, c2, ... ,cn, count(*)
FROM TableName1
INNER JOIN TableName2 on TableName1.ColName=TableName2.ColName
GROUP BY c1, c2,..., cn HAVING count(*) > 1;
Comments
Post a Comment