Skip to content
Advertisement

issues with when/case statement

I have a code where i have this statement

when d.ID in (1,2,3,4,5,6,7,8)
            then
            case
                    when d.today < '01/01/2001'
                    then
                        122
                    else
                        124
                    end
            end,
            case
                when d.today < '10/10/2018'
                then
                    121
                ELSE
                    125
                end
            end

case statement is throwing an error saying incorrect syntax, what i am missing here can’t seem to get it

Advertisement

Answer

Check This-

    CASE
    WHEN d.ID IN(1, 2, 3, 4, 5, 6, 7, 8)
        THEN 
            CASE
                WHEN d.today < '01/01/2001' THEN 122
                ELSE 124
            END
        ELSE 
            CASE
                WHEN d.today < '10/10/2018' THEN 121
                ELSE 125
            END
    END;
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement