Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I need to -Right join Patient p2 on p.PatientRef = p2.PatientRefp.ForeName = p2.ForeNameandp.Surname = p2.Surnameand p.DOB = p2.DOBandp.PatientRef <> p2.patientRefBut 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??xDKind Regards.
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.
winterh
Posting Yak Master
127 Posts
Posted - 2009-09-15 : 09:43:18
Yes sir, yes I am.
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts
Posted - 2009-09-15 : 09:54:43
maybe this?
select ForeName ,Surname,DOB, PatientRef from Patientsgroup by ForeName ,Surname,DOB, PatientRef having count(*) > 1
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 ??