Reputation: 1473
I have a MySQL table with a user column, and a category column. How can I write a MySQL query so that I find the number of users in each category? (I don't know the name of the categories beforehand).
Thanks!
Upvotes: 0
Views: 610
Reputation: 7078
Something like:
select category, count(users) from table
group by category;
Upvotes: 1
Reputation: 220902
select category, count(user) from my_table group by category
where my_table
is your table, category
is your category column, and user
is your user column
Upvotes: 3