I don't understand what you're trying to do. The query below is based on a table which includes a field named category_id
. And it uses GROUP BY category_id
to count the number of rows within each such group. The HAVING
clause limits the result set to only those groups whose count is at least 30.
SELECT category_id, COUNT(*)
FROM YourTable
GROUP BY category_id
HAVING COUNT(*) >= 30;
If that is nothing like what you're trying to accomplish, please give us more detailed information so we may better understand your situation. A brief set of sample data, and the output you want based on that sample, would help tremendously.