SQL script

Hi. Have a table that contains account information such as name, address, email, telephone number, etc.

Need syntax to return any persons name that have the same telephone number listed more than x times. So, when the query is executed, it will only look for telephone numbers that have been listed more than x times and will return the persons name and address.

Thanks in advance.
B0b_shiskaAsked:
Who is Participating?
 
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
Here you go:

select name, address
FROM ur_table
WHERE phone_no in (
Select telephone_no
FROM ur_table
Group by telephone_no
having COUNT(*) > 1)
0
 
Alpesh PatelAssistant ConsultantCommented:
select name, phone_no, Count(phone_no) FROM table
Group by name
having COUNT(phone_no) > 1)
0
 
Bhavesh ShahLead AnalysistCommented:
Hi,

Rajan Sir already gave you answer, but just for your knowledge


SELECT  name, address, email, phone_no
FROM table1 A,(Select name from table1 group by name having count(phone_no)>1) B
WHERE A.name = B.name



- Bhavesh
0
 
GhunaimaCommented:
Try this

 sql1.sql
0
 
hnasrCommented:
I go with PatelAlpesh's comment, but insert x in place of 1, from a form field. This allows for different x values.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.