GROUP BY
и ORDER BY
.+----+-------+
| id | value |
+----+-------+
| 1 | alpha |
| 2 | delta |
| 3 | beta |
| 4 | gamma |
| 5 | beta |
| 6 | beta |
| 7 | alpha |
| 8 | beta |
+----+-------+
SELECT `value` , COUNT( * ) AS `cnt`
FROM `testtable2`
GROUP BY `value`
ORDER BY `cnt` DESC
+-------+-----+
| value | cnt |
+-------+-----+
| beta | 4 |
| alpha | 2 |
| delta | 1 |
| gamma | 1 |
+-------+-----+