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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show one field if it is greater than the other....

Status
Not open for further replies.

fenneraj

Programmer
Jul 29, 2003
21
SE
Hi all,

Having real trouble with this one....

I have a table with a record ID (adID), advert text (ad), Submit date (sub_d) and update date (up_d). What I want to output is the ID, the ad text and ONE date. This date must be the 'newest' of the submit date and update date.

This date then needs to be sorted on so the last submitted or updated record is shown at the top.

Thanks in advance for any help provided...

Andy
 
Code:
select adID, ad,
       case when sub_d >= up_d then sub_d else up_d end as Dt
from table1
order by Dt desc

"A long life is when each day is full and every hour wide!"
(A Jewish Mentor)
M. [hourglass]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top