CASE

CASE
  WHEN search-condition1 THEN result1
  ...
  WHEN search-conditionn THEN resultn
  ELSE resultx
END

All the result1 values must have comparable data types. The ELSE resultx is optional and is set to ELSE NULL if not specified. The search-conditions are in the form of operand operator operand. For example:

CASE
  WHEN dept = 'HQ' THEN 'Headquarters'
  WHEN dept = 'FC' THEN 'Factory'
  ELSE 'Somewhere else'
END

A shorthand syntax is also permitted:

CASE valuet
  WHEN value1 THEN result1
  ...
  WHEN valuen THEN resultn
  ELSE resultx
END