The CASE/WHEN/THEN construct

If you need an expression to return different values depending on the input, you can use the CASE-WHEN-THEN construct.

The example below returns the text "zero" if the value of variable x is 0, the text "negative" if x is less than 0 and the text "positive" in all other cases.

case when x = 0 then "zero" when x < 0 then "negative" else "positive" end

Last updated