poofried Posted September 7, 2009 Share Posted September 7, 2009 ok, i have a mysql query that gets the sum of different columns. there are multiple sums that i need to be in order. how would i go about ordering all of the sums? Link to comment https://forums.phpfreaks.com/topic/173361-solved-order-mysql-table-by-sums/ Share on other sites More sharing options...
kratsg Posted September 7, 2009 Share Posted September 7, 2009 Well, in order to achieve this, SUM() is an aggregate function so some grouping helps. If you're looking at one column, do something similar to this: $query = "SELECT column,SUM(sum_col) AS sums FROM table GROUP BY column ORDER BY SUM(sum_col)"; Link to comment https://forums.phpfreaks.com/topic/173361-solved-order-mysql-table-by-sums/#findComment-913867 Share on other sites More sharing options...
poofried Posted September 7, 2009 Author Share Posted September 7, 2009 thanks, worked perfectly. Link to comment https://forums.phpfreaks.com/topic/173361-solved-order-mysql-table-by-sums/#findComment-913893 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.