query

P

Pass-the-Reality

I have a query that returns the records ID number, Phone Number and Name.
When I run my query, there are not any duplicate ID numbers, but there are
duplicate phone numbers. The reason is, there are individual records where
the same phone number was entered. How can I run a query to show that ONLY
shows those records with duplicate phone numbers? Example. I only want to
see the below records 2 and 3

ID Phone Name
1 5555555 Mike
2 6666666 Lisa
3 6666666 Jeff
 
J

Jerry Whittle

Select *
From YourTable
Where Phone In (
Select Phone
From YourTable
Group By Phone
Having Count(phone) >1)
Order by Phone, Name;

Make sure that the table and field names are correct especially both
"YourTable"s.
 
S

SuzyQ

This will give you the phone numbers that are duplicated. If you need to
know which records have the duplication, you can do a join on phone number
back to YourTable to see the ID numbers
 
B

Bob Quintal

This will give you the phone numbers that are duplicated. If you
need to know which records have the duplication, you can do a join
on phone number back to YourTable to see the ID numbers

SuzyQ,

Jerry's SQL does return the whole row including the id numbers.

Q
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top