Michael Buluma Michael Buluma - 24 days ago 9
MySQL Question

How to sum each user totals per category

table preview

I have the above table which I'd like to sum all users total per category. Totals for user 1, User 2, ..., user 20 to be shown at the end of the table. how can i achieve this in Joomla?

Answer

This will work

SELECT `Category_ID` ,SUM( `user1` ) AS user1, SUM( `user1` ) AS user2 , ...
FROM `table_name`
GROUP BY `Catagory_ID`