![]() |
|
|
#1 |
|
Junior Member
Join Date: Nov 2004
Posts: 3
|
Need results sorted by 2 fields, not 1
Hello,
I'm trying to sort a resultset by 2 fields. I have a table "program" which has dozen of fields (program specs). When a new program is inserted, a date field called Date_Submitted has the current date. When the program is updated with new information, the field named Date_Updated get the current date. I want to be able to return a resultset that is sorted by, both, Date_Submitted and Date_Updated so that I can list on my site which programs are new and which have been updated. I have something that sort of works: SELECT * FROM program ORDER BY Date_Submitted desc, Date_Updated desc Any ideas? thanks, freeware |
|
|
|
|
|
#2 |
|
Junior Member
Join Date: Nov 2004
Posts: 3
|
Re: Need results sorted by 2 fields, not 1
Never mind. I got it.
I anyone is interested, here is my solution: SELECT IF(Date_Submitted > Date_Updated, Date_Submitted, Date_Updated) as MaxDate, Program_Name, more fields.., from program Order by MaxDate desc freeware Last edited by freeware : 11-20-2004 at 09:29 AM. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Exporting only certain fields? Possible? | Andreescu | SQL syntax | 1 | 11-17-2004 04:47 AM |
| Assistance with setting up fields, please | ChrisJ | Looking for an employee or consultant | 0 | 09-20-2004 08:18 PM |