Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-04-13
5
Medium Priority
?
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 22

Accepted Solution

by:
dportas earned 600 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 200 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 200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

730 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