CASE 'inside' COALESCE

  • Hiya,

    I have the following statement;

    ISNULL(COALESCE(ap.ABP_Name,at.ABT_Name,sp.SKP_Name,st.SKT_Name,h.HLT_Name),'None') Absence_Reason

    and the 2 columns I have underlined I need to change whatever the value is, if not null, to a specific word. I have tried using CASE WHEN <column> IS NOT NULL THEN 'Text' but it errors out.

    These 2 columns are the sickness reason and for 'decency' reasons we do not want to public show the real reason, rather change it to just 'Sickness'.

    Thanks

  • Hi there,

    Have you tried putting END keyword in CASE?

    CASE WHEN <column> IS NOT NULL THEN 'Text' END

    Just trying to help.. 😛

  • I'm sorry, but I don't understand what you're trying to do. The statement you have posted will return just one column, but you appear to want to return at least two. And please will you be more specific than saying it "errors out". What is the error message?

    By the way, you don't need the ISNULL. Just add 'None' to the end of your list of arguments for COALESCE.

    John

  • D'oh. It's Monday!

Viewing 4 posts - 1 through 3 (of 3 total)

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