I have a SQL table called \"posts\" that looks like this:
id | category ----------------------- 1 | 3 2 | 1 3 | 4 4 | 2 5 | 1 6 | 1 7 | 2
SELECT category, COUNT(*) AS `num` FROM posts GROUP BY category