03-30-2012 03:35 PM
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.
03-30-2012 03:42 PM
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"