How can I build a query to do the following?
- Grouping by phonenumber
- Where That Grouping has over 5 different names
data fields: id, phonenumber, name
I've tried:
SELECT count(phonenumber), phonenumber, GROUP_CONCAT(name)
FROM list
group by phonenumber
having count(phonenumber) > 5
but it's timing out, so not sure if that's the right format.
fake data:
id | phonenumber | name
1 | 555-5555 | joe
2 | 444-4444 | joe
3 | 555-5555 | joe
4 | 555-5555 | dan
5 | 555-5555 | Ben
6 | 555-5555 | Griff
7 | 555-5555 | Sam
8 | 555-5555 | Jim
desired output:
count(phonenumber | phonenumber | GROUP
7 | 555-5555 | joe, dan, Ben, Griff, Sam, Jim