Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to identify and flag duplicate rows based on single
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01053662
Message ID:
01053687
Views:
15
This message has been marked as the solution to the initial question of the thread.
DELETE patients
	FROM patients pt
	WHERE EXISTS ( SELECT * FROM patients 
                        WHERE mpinumber = pt.mpinumber AND  PatientID < pt.PatientID)
>I have a table that I need to identify duplicate entries based off the value of a single column, and delete all but one of the duplicate entry records.
>
>Was hoping someone had a routine already for something like this. I found this example, but it doesn't work, gives error on the where (patientID,mpinumber) line:
>
>
>delete from patients
>  where (PatientID, mpinumber)
>    not in
>    ( select min(PatientID), mpinumber
>         from patients group by mpinumber)
>
>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform