maxudaskin Posted January 23, 2008 Share Posted January 23, 2008 Here is what I want to do. I have a database with flight hours that are specifically assigned to a particular user. I wanted to have the hours added together according to the users... so if there were three entries for 0100, such as 3, 1.5, and 7.5, I want to have them added up and then the top ten users with the most hours to be sorted DESC. Link to comment https://forums.phpfreaks.com/topic/87440-solved-no-idea-what-to-do/ Share on other sites More sharing options...
revraz Posted January 23, 2008 Share Posted January 23, 2008 Sounds like you want to use SUM and GROUP BY, both are DB/MySQL functions. Link to comment https://forums.phpfreaks.com/topic/87440-solved-no-idea-what-to-do/#findComment-447209 Share on other sites More sharing options...
The Little Guy Posted January 23, 2008 Share Posted January 23, 2008 Maybe something like so: "SELECT SUM(totaltime) as sumValue FROM tableName WHERE pid = 0100 GROUP BY pirepid" Link to comment https://forums.phpfreaks.com/topic/87440-solved-no-idea-what-to-do/#findComment-447212 Share on other sites More sharing options...
Barand Posted January 23, 2008 Share Posted January 23, 2008 The only 0100 I can see is in the pid column so SELECT pid, SUM(totaltime) as sumValue FROM tableName GROUP BY pid ORDER BY sumValue DESC LIMIT 10 Link to comment https://forums.phpfreaks.com/topic/87440-solved-no-idea-what-to-do/#findComment-447325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.