using muliple conditions HELP

  • SELECT CASE WHEN CurrentSickTerm= 'LT'THEN 'Long Term' ELSE if CurrentSickTerm= 'ST'THEN 'Short Term' else 'NULL' END AS ColumnNameFROM dbo.ViewName

    This does not work I need another way to write this

  • Your syntax is wrong from BOL:-

    SELECT au_fname, au_lname,

    CASE state

    WHEN 'CA' THEN 'California'

    WHEN 'KS' THEN 'Kansas'

    WHEN 'TN' THEN 'Tennessee'

    WHEN 'OR' THEN 'Oregon'

    WHEN 'MI' THEN 'Michigan'

    WHEN 'IN' THEN 'Indiana'

    WHEN 'MD' THEN 'Maryland'

    WHEN 'UT' THEN 'Utah'

    END AS StateName

    FROM pubs.dbo.authors

    ORDER BY au_lname

    Facts are stubborn things, but statistics are more pliable - Mark Twain
    Carolyn
    SQLServerSpecialists[/url]

  • Help - it does not work within a view as it does not accept case statements

  • View definitions support Case functions just fine.

    The query designer may not, but then just don't use the query designer. (I would never use it anyway).

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

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

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