Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Finding Duplicates

Author  Topic 

winterh
Posting Yak Master

127 Posts

Posted - 2009-09-15 : 09:22:36
I need to -

Right join Patient p2 on p.PatientRef = p2.PatientRef

p.ForeName = p2.ForeName
and
p.Surname = p2.Surname
and
p.DOB = p2.DOB
and
p.PatientRef <> p2.patientRef

But my logic is eluding me today.

How would I write this report to find duplicates (As shown above)

??

Any Help would be appreciated

winterh
Posting Yak Master

127 Posts

Posted - 2009-09-15 : 09:29:46
Whoops Sorry,

All i need to do is create a temp table holding all the patientRefs, names dobs (declare @patient2 as table etc...) , and then join this to the patient table and use the where statement as mentioned before... That would work right??

xD

Kind Regards.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-15 : 09:32:20
Are you talking about ONE table and a select to show duplicates in it?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

winterh
Posting Yak Master

127 Posts

Posted - 2009-09-15 : 09:43:18
Yes sir, yes I am.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-09-15 : 09:54:43
maybe this?

select ForeName ,Surname,DOB, PatientRef  
from Patients
group by ForeName ,Surname,DOB, PatientRef
having count(*) > 1
Go to Top of Page

winterh
Posting Yak Master

127 Posts

Posted - 2009-09-15 : 16:09:14
THat wouldnt work properly, as the patientrefs need to be different, but the dob fullnames the same etc. You know what I mean ??
Go to Top of Page
   

- Advertisement -