Hey Guys and Girls!
Imagine you have the following table:
Name | SIN | DOB
--------------------------------------------------------
Steve | 12341234 | 19750827
Jeff | 43214321 | 19740726
Steve | 12341234 | 19750827
Then imagine that there was a whole bunch of other information in there too with lots more records and you can almost certainly guarantee that Steve whose birthdate is 19750827 is not the only duplicate in the table. The SIN is meant to be a primary key except someone messed up and took it out. It's now your job to reassign SIN as a primary key but of course before you can do that you need to remove the duplicates.
What I'd like to do is something like:
DELETE FROM tblStudentData WHERE SSN IN (SELECT SSN FROM tblStudentData GROUP BY SSN HAVING ((Count(*))>1))
but of course that would delete ALL my duplicate records rather than just one of them.
I know there are other options - making a new table, adding another unique identifier but I'd like a nice clean SQL query if there was such a thing that could fix this issue - something like DELETE DISTINCT would be nice! :-)
Any help appreciated.
