Sql Case Statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • salex
    New Member
    • Oct 2006
    • 7

    #1

    Sql Case Statement

    Hi,
    I'm new to SQL, and I'm hoping to get some help in selecting a value based on a hierachy.

    What I'm trying to achieve is get the campus phone number, and if this is not available, then go down the hierarchy:
    if campus phone is null then get business_phone
    if business_phone is null then get permanent_phone

    columns in the table are defined as follows:
    emp_id, tele_code, tele_phone
    1234 CA (campus) NULL
    1234 PR(permanent) xxx-xxxx
    1234 BU(business) xxx-xxxx

    Thank you in advance for all the help.
    salex
Working...