I need to delete all records that have duplicate values, So I would only end up with John Doe with the rows below.
LastName, FirstName and DateofBirth
Doe Jane 4/15/1936
Doe Jane 4/15/1936
Doe Jane 4/15/1936
Doe John 6/12/1978
I used the code below but it left 2 rows. I want to delete all Jane Doe in this case since they are the same.
WITH cte AS (
SELECT LastName, FirstName, DateOfBirth , ROW_NUMBER() OVER(PARTITION BY LastName, FirstName, DateOfBirth
ORDER BY LastName) AS rn FROM PatientDemographics2 ) DELETE FROM cte WHERE rn > 1