How to get the count of each distinct value in a column? [duplicate]

SELECT
  category,
  COUNT(*) AS `num`
FROM
  posts
GROUP BY
  category

Leave a Comment