I need some help on a select if it is possible. Take for Example the following data.
-------------------------------------- | RUSH | FileNumber | PTime | PDate | -------------------------------------- | 1 | 1-1023-001 | 08:00 | 12/04 | | 1 | 1-4444-001 | 06:00 | 12/04 | | 0 | 1-1023-002 | 14:00 | 12/09 | | 1 | 1-3333-000 | 08:30 | 12/04 | | 0 | 1-1023-003 | 11:00 | 12/10 | | 1 | 1-9999-123 | 08:00 | 12/04 | | 0 | 1-9999-124 | 09:30 | 12/09 | | 0 | 1-6655-021 | 08:40 | 12/11 | | 0 | 1-9999-125 | 10:00 | 12/15 | | 1 | 1-7654-043 | 08:00 | 12/05 | | 0 | 1-6655-022 | 13:30 | 12/15 | | 0 | 1-9868-000 | 14:00 | 12/05 | -------------------------------------- To end up grouped like this. -------------------------------------- | RUSH | FileNumber | PTime | PDate | -------------------------------------- | 1 | 1-4444-001 | 06:00 | 12/04 | | 1 | 1-1023-001 | 08:00 | 12/04 | | 0 | 1-1023-002 | 14:00 | 12/09 | | 0 | 1-1023-003 | 11:00 | 12/10 | | 1 | 1-9999-123 | 08:00 | 12/04 | | 0 | 1-9999-124 | 09:30 | 12/09 | | 0 | 1-9999-125 | 10:00 | 12/15 | | 1 | 1-3333-000 | 08:30 | 12/04 | | 1 | 1-7654-043 | 08:00 | 12/05 | | 0 | 1-9868-000 | 14:00 | 12/05 | | 0 | 1-6655-021 | 08:40 | 12/11 | | 0 | 1-6655-022 | 13:30 | 12/15 | -------------------------------------- Basically, I need this. If it is a RUSH (1), It needs to be first If there are duplicate files (1-9999 or 1-1023) and one of them is a rush They need to be grouped together. Then sort it by PDate and PTime I have tried several group by combinations but no luck so far. Any help will be appreciated. Thanks Roger SQL, MySQL --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php