4

I want to say if "field1" is (this or this or this) And "field2" is (this or this or this) then Z.

What is wrong with my expression?

(There are more lines after the first, but I excluded them because they follow the same scheme). I tried replacing When with IN but that doesn't work either.

CASE 
  WHEN "X" =  ('X1', 'X2') AND "Y" =  ('Y1', 'Y2', 'Y3', 'Y4') THEN Z
END

1 Answer 1

5

Use the IN operator:

The IN operator is a shorthand for multiple OR conditions.

CASE

WHEN "X" IN('X1', 'X2') AND "Y" IN('Y1', 'Y2', 'Y3', 'Y4') THEN Z

END
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.