Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem ordering query results.... 1

Status
Not open for further replies.

blondends

Technical User
Apr 25, 2003
84
GB
HI,

I have a table that has 2 fields that hold dates. I am trying to order the results of the query so that the records with the most recent dates come out first. I can't work this one out - i can obviously return the results grouped by one of the date fields but not by both.

Any ideas ??

Chris
 
So you want to take the most recent of the tow dates for each row and then order by those, latest first?

Code:
ORDER BY CASE WHEN date1 > date2 THEN date1 ELSE date2 END DESC

--James
 
Excellent !! Thank you very much - that has help hours of reading and hair pulling !! STAR for you !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top