I am comparing two dates and trying to determine the max of the two dates. A null date would be considered less than a valid date. I am using the following case statement, which works - but feels very inefficient and clunky. Is there a better way?
update @TEMP_EARNED
set nextearn = case when lastoccurrence is null and lastearned is null then null
when lastoccurrence is null then lastearned
when lastearned is null then lastoccurrence
when lastoccurrence > lastearned then lastoccurrence
else lastearned end;
(This is in MS SQL 2000, FYI.)