Solved

Fine records with duplicate ssn and date of birth but different record ids

Posted on 2009-04-13
5
310 Views
Last Modified: 2012-05-06
I am stuck on this query which seems like it should be simple.
I have a table that has five columns:
member_id (PK)
last_name
first_name
social_security_no
birthdate

I am trying to find all records where a single person (same social_security_no and birthdate) has one or more different member_ids.
Any assistance is appreciated. Thanks.
0
Comment
Question by:c4e41961
5 Comments
 
LVL 22

Accepted Solution

by:
dportas earned 150 total points
ID: 24133153
SELECT *
FROM tbl t
WHERE EXISTS
 (SELECT 1
  FROM tbl
  WHERE social_security_no = t.social_security_no
   AND birthdate = t.birthdate
   AND member_id <> t.member_id);
0
 
LVL 1

Assisted Solution

by:joshbenner
joshbenner earned 50 total points
ID: 24133160
Something like this:
SELECT

  *,

  COUNT(*)

FROM myTable

GROUP BY social_security_no, birthdate

ORDER BY COUNT(*) DESC

Open in new window

0
 
LVL 1

Expert Comment

by:joshbenner
ID: 24133162
You could add a HAVING COUNT(*) > 1
0
 
LVL 15

Assisted Solution

by:MNelson831
MNelson831 earned 50 total points
ID: 24133174
Select * from MyTable where SSN in (

Select SSN from MyTable having Count(*) >1 group by SSN)
0
 

Author Closing Comment

by:c4e41961
ID: 31569689
Thanks!  I appreciate your solutions!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now