The techie in me RSS 2.0
 Monday, August 30, 2010

Recently I was trying to find duplicate records in a table. The records are considered duplicate if two columns in different records has the same value. For example if first name and last name is same in record1 and record2, they considered as duplicate.

The below query will help to find the duplicate records.

SELECT fname, lname, COUNT(*) AS DuplicateCount FROM [Users]
GROUP BY fname, lname HAVING COUNT(*) > 1
ORDER BY COUNT(*), fname.

 

(I know this is pretty simple one, but most of the time you struggle for the simplest query :) so thought of sharing it)

Monday, August 30, 2010 10:13:00 PM (GMT Standard Time, UTC+00:00)  #    Comments [1] -
Database
About me
Name : Rujith Anand Send mail to the author(s)
Archive
<August 2010>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234
Blogs I read
Disclaimer

Disclaimer
Postings are provided as is with no warranties, and confer no rights. Opinions expressed here are my own delusions; my employers at best shake their heads and sigh, at worst repudiate the content with extreme prejudice, whenever it manages to appear on their radar.

© Copyright 2012
Rujith Anand

Statistics
Advertisement
All Content © 2012, Rujith Anand