I have TableA which contains:
ID | CATEGORY | NAME
-------------------------
1 | A | NAME01
2 | B | NAME02
3 | C | NAME03
4 | D | NAME04
5 | B | NAME05
So how can I count which of the Categorys in my table I have the most?
We can see it is the Category B, but in my real table I have more than 200 records added.
In the table I have 5 different Categories.
It seems like you can just use an aggregate function (
count()) and agroup by:See SQL Fiddle with Demo
If you then want to return only the record with the most, you can add a
LIMITto it:See SQL Fiddle with Demo