January 25, 2005 at 4:51 pm
How can I modify the following so it will
compare the 1stDate and 2ndDate fields,
extracting the "most current date" ?
----------------------------------------
SELECT Email, 1stDate, 2ndDate
FROM orders
----------------------------------------
Orders (table layout)
Email, 1stDate, 2ndDate
test@test.com, 20040105, 20050105
john@doe.com, 20030403, 20020503
----------------------------------------
Desired Result
Email, CurrentDate
test@test.com, 20050105
john@doe.com, 20030403
January 25, 2005 at 4:59 pm
Select
Email,
Case
When 1stDate > 2ndDate Then 1stDate
Else 2ndDate
End As MostCurrentDate
From Orders
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply