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. Quote 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. Quote 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" Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.