Yes, your
SELECT
CASE WHEN ScheduleTime1 > ScheduleTime2 THEN
CASE WHEN ScheduleTime1 > ScheduleTime3 THEN ScheduleTime1
ELSE ScheduleTime3
END
ELSE
CASE WHEN ScheduleTime2 > ScheduleTime3 THEN ScheduleTime2
ELSE ScheduleTime3
END
END
FROM ...
and the one I posted
SELECT CASE
WHEN MAX(col1) > MAX(col2) THEN
CASE
WHEN MAX(col1) > MAX(col3) THEN MAX(col1)
ELSE MAX(col3)
END
WHEN MAX(col2) > MAX(col3) THEN MAX(col2)
ELSE MAX(col3)
END
FROM max_t
look pretty similar. Actually I've overseen your second reply in this thread while first reading.
And yes, you're right that there are cases where such a deisgn would be appropriate. However, given the names of the columns and the comment by the OP "not to suggest to have just one column" can lead to the conclusion that there might be a design flaw present. Anyway, I think he has now some good working solutions.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]