Hi. I have a query like this: SELECT t1.fullname,t1.user_id,t3.name FROM persdb_users t1 LEFT JOIN persdb_user_groups t2 ON t1.user_id = t2.user_id LEFT JOIN persdb_groups t3 ON t2.group_id = t3.group_id WHERE registered like '%YEAR-MONTH%' AND active = 1 ORDER BY t3.name Code (markup): What it does is it gets the users full name and group name based on the selected year and month (substitute the YEAR and MONTH for actual values) - I'd like to be able to do a count for each group (t3.name) - how would I do that within this query?
Did you try this ? SELECT t3.name, count(*) FROM persdb_users t1 LEFT JOIN persdb_user_groups t2 ON t1.user_id = t2.user_id LEFT JOIN persdb_groups t3 ON t2.group_id = t3.group_id WHERE registered like '%YEAR-MONTH%' AND active = 1 GROUP BY t3.name
The question is 3 years old... I don't really remember what I did to solve the problem, but I'm pretty sure it has been solved. I will do a check of the code-base and see if I can find out how/what I did to fix it, or if I just ended up doing something else alltogether.