Case statement for multiple columns

It doesn’t appear that your desired logic is complete. Such as what do you actually want the value to be retain current colA value? and you are writing colb = 1 then colC = ‘Tom1’… I will assume then is supposed to be and.

CASE
   WHEN colB = 1 and colC = 'Tom1' THEN ????
   WHEN LEFT(colD) = 'Jef' AND colC = 'Tom2' THEN ????
   ELSE NULL
END

If you just want to retain the ColA Value then you can actually combine yoru case statements with an OR

CASE
   WHEN (colB = 1 and colC = 'Tom1')
        OR (LEFT(colD) = 'Jef' AND colC = 'Tom2') THEN colA
   ELSE NULL
END

Leave a Comment