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
Tuesday, February 15, 2011 6:46:41 PM (GMT Standard Time, UTC+00:00)
Thanks, Rujith.
tharpa
Comments are closed.
About me
Name : Rujith Anand Send mail to the author(s)
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
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