Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to identify and flag duplicate rows based on single
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01053662
Message ID:
01053687
Vues:
17
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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform