I have been looking for a way to do a MySQL select to get all the most occuring values. All the solutions i have found where with using LIMIT 1, but this doesn't help if there are more than one value that occur the same amount of times. E.g:
customer
| ID | FirstName |
|---|---|
| 1 | Bob |
| 2 | Tom |
| 3 | Bob |
| 4 | Robert |
| 5 | Tom |
| 6 | Timothy |
The Select for most occuring FirstNames should result in:
| FirstName |
|---|
| Bob |
| Tom |
Since both occur twice.
I have tried the following:
SELECT FirstName FROM (
SELECT FirstName, COUNT(FirstName) as counter FROM customer
GROUP BY FirstName
HAVING counter = MAX(counter)
) s
But this doesn't seem to work, i would really appreciate a nudge in the right direction.