MySQL LIMIT before grouping?

I want LIMIT to group the results to 30, but instead I group all the rows and then limit them to 30 groups. How can I do the opposite?

SELECT *, COUNT(*) AS COUNT FROM `Posts` GROUP By `Category` LIMIT 30
+5
source share
1 answer
SELECT *, COUNT(*) AS COUNT FROM (SELECT * FROM `Posts` LIMIT 30) t GROUP By `Category`
+8
source

All Articles