If you are saddled with the task of finding duplicate rows in a table using SQL.
It is a simple task even though it is not a place you should find yourself because you need to make sure your records are well indexed at the time of creating your table. Now that the worst has happened. All you need do is to select the row that has the duplicate values and count for each of the rows using a GROUP BY clause. For convenience sake, you can order by the same column in question as shown below:
SELECT CurrentDate,
COUNT(*)
FROM
tblSingleRate
GROUP BY
CurrentDate
ORDER BY CurrentDate
CurrentDate Count(*)
2007-03-12 1
2007-03-13 2
2007-03-14 2
2007-03-15 1
2007-03-12 1
2007-03-13 1
2007-03-14 2
2007-03-15 1
Duplicates are marked in red.
QED!
It is a simple task even though it is not a place you should find yourself because you need to make sure your records are well indexed at the time of creating your table. Now that the worst has happened. All you need do is to select the row that has the duplicate values and count for each of the rows using a GROUP BY clause. For convenience sake, you can order by the same column in question as shown below:
SELECT CurrentDate,
COUNT(*)
FROM
tblSingleRate
GROUP BY
CurrentDate
ORDER BY CurrentDate
CurrentDate Count(*)
2007-03-12 1
2007-03-13 2
2007-03-14 2
2007-03-15 1
2007-03-12 1
2007-03-13 1
2007-03-14 2
2007-03-15 1
Duplicates are marked in red.
QED!
Comments