+--------+-----------+------------+ | jobnum | milestone | shipdate | +--------+-----------+------------+ | 96-655 | 4 | | | 96-655 | 2 | | | 96-655 | 0 | 2003-12-04 | | 98-308 | 0 | 1973-05-11 | | 98-308 | 4 | | | 98-316 | 0 | 1973-06-11 | | 98-316 | 4 | | | 98-500 | 2 | | | 98-327 | 4 | | | 98-327 | 0 | 1973-08-11 | +--------+-----------+------------+
when I add "group by jobnum order by milestone" I get:
+--------+-----------+------------+ | jobnum | milestone | shipdate | +--------+-----------+------------+ | 98-308 | 0 | 1973-05-11 | | 98-316 | 0 | 1973-06-11 | | 96-655 | 4 | | | 98-327 | 4 | | +--------+-----------+------------+ but what I really want is this:
+--------+-----------+------------+ | jobnum | milestone | shipdate | +--------+-----------+------------+ | 98-308 | 0 | 1973-05-11 | | 98-316 | 0 | 1973-06-11 | | 96-655 | 0 | 2003-12-04 | | 98-327 | 0 | 1973-08-11 | | 98-500 | 2 | | +--------+-----------+------------+
Clearly, mysql is grouping first and then ordering. I suppose that's reasonable, but I really want to order the results internally first and then group so that the displayed row from each group is the smallest value (and then maybe do some more sorting on shipdate, but that's another issue).
Is there a way to do this?
Thanks, Michael
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]