t_machine Posted February 1, 2008 Share Posted February 1, 2008 I have a table that has columns "id", "hits" and votes" . Is there a way to write the sql query that will sum(hits)+sum(votes) and display the results where the totals are the largest. Any help will be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/88810-sum-values-in-mysql/ Share on other sites More sharing options...
Barand Posted February 1, 2008 Share Posted February 1, 2008 SELECT id, SUM(hits)+SUM(votes) as total FROM mytablename GROUP BY id ORDER BY total DESC Link to comment https://forums.phpfreaks.com/topic/88810-sum-values-in-mysql/#findComment-454914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.