MySQL Forums
Forum List  »  Newbie

ORDER BY Problem
Posted by: Thomas Rushworth
Date: February 26, 2007 05:01PM

The column duration in the reports table is type = time. The following query produces the results below it. My question is why does the 9th entry appear where it does? Or better yet, How can I get it to sort "correctly?" That's "correctly" by my understanding, not necessarily SQL's. :)


SELECT a.pilot_num AS Pilot,
sec_to_time(sum(time_to_sec(b.duration))) AS Duration
FROM pilots AS a, reports AS b
WHERE a.pilot_id = b.pilot_id AND month(now())=month(b.date) AND year(now()) = year(b.date)
GROUP BY Pilot
ORDER BY Duration DESC
LIMIT 10


Pilot Duration
CAA165 79:27:00
CAA148 65:53:00
CAA001 31:07:00
CAA170 19:13:00
CAA131 16:29:00
CAA142 14:56:00
CAA183 14:37:00
CAA156 12:06:00
CAA161 115:06:00
CAA071 10:50:00

Options: ReplyQuote


Subject
Written By
Posted
ORDER BY Problem
February 26, 2007 05:01PM
February 27, 2007 03:36AM
February 27, 2007 07:11PM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.