Case statement with other variable

  • I have a case statement that was very straightforward

    CASE

    code

    WHEN '#' Then 'A'

    WHEN '$' THEN 'B'

    WHEN '%' then 'B'

    WHEN '2' Then 'A'

    WHEN '3' THEN 'c'

    WHEN '4' then 'B'

    ELSE ''

    End

    Now I've been asked to change it to add another vaiable, but just for one code.  All of them stay the same except when code is 2.

    If code 2 and LocationID is either '101','102','103' then it should be 'A'

    code 2 and LocationID is either '110','112','113' then it should be 'B'

    Is this possible?  Thanks, J

    '

  • CASE

    WHEN code= '#' Then 'A'

    WHEN code = '$' THEN 'B'

    WHEN code = '%' then 'B'

    WHEN code = '2' AND LocationID IN ('101', '102', '103') Then 'A'

    WHEN code = '2' AND LocationID IN ('110', '112', '113') Then 'B'

    WHEN code = '3' THEN 'c'

    WHEN code = '4' then 'B'

    ELSE ''

    End

     


    N 56°04'39.16"
    E 12°55'05.25"

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

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