• LinksUp (9/2/2013)


    vignesh.ms (9/2/2013)


    is there any other way ?

    This way is fine. It just needs to be modified slightly to handle nulls.

    Why would you need to handle nulls? Null won't be greater than anything.

    I reviewed the results ans checked the need for a null validation, however it's not needed on all columns and date zero is possible.

    SELECT a, b, c, CASE WHEN a >= ISNULL(b, CAST( 0 AS DATETIME)) AND a >= ISNULL(c, CAST( 0 AS DATETIME)) THEN a

    WHEN b >= c THEN b

    ELSE c END

    FROM sample

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2