Conditional

  • I have a table with a Employee Status column with values 0 or 1 or 2

    Instead of printing the values I would like to view the result as

    if the value is 0 then it should output Active

    if the value is 1 then it should output Leave

    if the value is 2 then it should output Terminated

    Thanks

  • nfpacct (1/18/2012)


    I have a table with a Employee Status column with values 0 or 1 or 2

    Instead of printing the values I would like to view the result as

    if the value is 0 then it should output Active

    if the value is 1 then it should output Leave

    if the value is 2 then it should output Terminated

    Thanks

    Read about CASE in Books Online.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • 'case when' may give you solution but I suggest create a reference/lookup table for those values and join it with your table to normalize your data.

    "Often speak with code not with word,
    A simple solution for a simple question"

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

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