Need a help in case statement...

  • Hi,

    I need a help in case statement.

    I want to know whether we can set value for two fields in case statement

    for example

    Select

    (CASE

    WHEN SUnits> 0

    THEN 'xxx'

    WHEN RUnits > 0

    THEN 'yyy'

    END)

    Here I need to set another value as well in Then statement

    I want the above to be like this

    Select @data=

    (CASE

    WHEN SUnits> 0

    THEN 'xxx' ,@dsr=1

    WHEN RUnits > 0

    THEN 'yyy', ,@dsr=0

    END)

    Is it possible?

    Else the below statement is the only way

    Select @data=

    (CASE

    WHEN SUnits> 0

    THEN 'xxx'

    WHEN RUnits > 0

    THEN 'yyy',

    END),

    @dsr= (CASE

    WHEN SUnits> 0

    THEN 1

    WHEN RUnits > 0

    THEN 0

    END)

    Here I need to

  • No, it is not possible. You'll need to enter the case statement twice.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

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

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