replace null with another column

  • MMartin1 (1/10/2017)


    drew.allen (1/10/2017)


    MMartin1 (1/9/2017)


    You forgot the NOT.

    SELECT CASE WHEN NULL IS NOT NULL THEN NULL ELSE NULL END;

    How about

    SELECT CASE WHEN NULL IS NOT NULL THEN NOT NULL ELSE NULL END

    ?

    same logical result to the original expression COALESCE(null, null) . Though if you keep going these nulls can start to become a head spinner.

    CASE cannot return a Boolean predicate, and since NOT is a Boolean operator, you cannot return NOT NULL in your THEN clause.

    Drew

    Hence why I mentioned logically 🙂

    Actually it's not logically equivalent. What I wrote is the logical equivalent. Let me clarify.

    SELECT CASE WHEN NULLa IS NOT NULL THEN NULLa ELSE NULLb END;

    You're returning the value being tested NULLa not the test that is being performed (IS NOT NULL).

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • It is as far as the end result being deterministic and resulting in NULL. I thought that was the scope here since your/our statement(s) will not even execute in SQL Server, as Brandi pointed out 😀

    ----------------------------------------------------

  • This thread went nowhere, very quickly, with the isnull discussion totally irrellevant to the OP's question. I hope you can still filter out the various options presented, komal145?



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

Viewing 3 posts - 31 through 32 (of 32 total)

You must be logged in to reply to this topic. Login to reply