SQLTeam.com | Weblogs | Forums

Query to output duplicate client records

Is this how to get the duplicate records, Here duplicate is mainly by dob. Names are spelt differently often.SELECT a.people_id, a.full_name, a.id_no, a.dob, a.last_name, a.first_name
FROM [evolv_cs].[dbo].[all_clients_view] a
LEFT OUTER JOIN
(SELECT b.people_id, b.dob, b.full_name, b.last_name, b.first_name
FROM [evolv_cs].[dbo].[all_clients_view] b
WHERE a.people_id = b.people_id and a.dob = b.dob)

Select * from evolv_cs].[dbo].[all_clients_view] a where exists(
Select 1 from evolv_cs].[dbo].[all_clients_view] dup where dup.dob = a.dob
Group by dup.dob
Having count(1) > 1
)

1 Like

Thank you. It shows the dupes on the dob.