Community
Showing results for 
Search instead for 
Do you mean 
Reply

Query contacts with duplicate phone numbers.

New Member
Posts: 19
Country: USA

Query contacts with duplicate phone numbers.

Hi.

I expected the following SQL to produce a list of contacts with duplicate phone numbers

 

     SELECT phone, COUNT(phone) FROM contact GROUP BY phone HAVING (COUNT(phone) > 1)

 

But it doesn'tt.  It returns all contact records

 

Is the HAVING clause not supported? 

 

I was surprised the following could be parsed and produces the same full recordset

     SELECT phone, COUNT(phone) FROM contact GROUP BY phone HAVING (ThisDoesntMatter = NorDoesThis)

 

Any help appreciated.

New Member
Posts: 19
Country: USA

Re: Query contacts with duplicate phone numbers.

Nevermind.  This worked to get the total count, without using HAVING

 

 

 "SELECT count(*) from (SELECT phone,count(phone) AS cop FROM contact GROUP BY phone) n WHERE cop > 1"