Skip to content
Advertisement

MySQL Grouping using group_concat and then Group BY

I have a table like this:

enter image description here

Basically, I want to group all names and give the count of such groupings like:

enter image description here

Since there are 2 users with cooking and cleaning, 1 for washing and 4 for cooking.

I am trying to use group_concat

However, this will not work as I need to group by the groupings and then get count of those groupings.

I am not getting how to group on the groupings and then get the count.

Thanks in advance and I appreciate any heads up!

UPDATE As per the answer I tried

However, I get it as

shoudnt count be 4 for cooking?

Advertisement

Answer

I’d wrap this query with another query to coubt the grouped data:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement