Choosing to select a column based on null values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lachlanpearce
    New Member
    • Dec 2011
    • 4

    Choosing to select a column based on null values

    Hi,
    I have a table with these values:

    Code:
    =========================================
    column1        column2        column3
    firstname      462            david
    lastname       smith          NULL
    =========================================
    I want to write a select query that will select either column2 or column3 based on whether column 3 is not null and output something like this:
    Code:
    =========================================
    column1        column2
    firstname      dave
    lastname       smith
    =========================================
    So, if column3 is not null, select that column as column2, otherwise select column2.

    Is this even possible?
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Yes, use the ISNULl() function.

    Happy Coding!!!


    ~~ CK

    Comment

    Working...