Case When Questino

  • I have a CASE WHEN in with my SELECT statement and I can not get it to return the desired value when ever a column is NULL.

    Basically if the column is NULL I want to return N/A instead of NULL.

    Here is a pic to help:

    Thanks again !

    Erik

    Dam again!

  • Hey,

    There is an ISNULL function that you may consider using.

    Select isnull(p.NAME, 'N/A') would do the same thing as the case statement.

    Not sure it will solve your Null problem though...

    ~PD

  • That works perfect !

    Thanks

    Dam again!

  • ...or in the case statement

    CASE WHEN p.Name is null then 'N/A' ELSE p.Name END

    (but isnull is better here.)

    The issue is that nothing is equal to null i.e. p.Name = null returns false.

  • You can also use COALESCE(ColumnName, 'N/A')

    Todd Fifield

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

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