CASE <case-operand>
WHEN when-condition THEN result-expression
<...WHEN when-condition THEN result-expression>
<ELSE result-expression>
END
case-operand
is a valid sql-expression that resolves to a table column whose values are compared to all the when-conditions
when-condition
When case-operand is specified, when-condition is a shortened sql-expression that assumes case-operand as one of its operands and that resolves to true or false.
When case-operand is not specified, when-condition is an sql-expression that resolves to true or false.
result-expression
is an sql-expression that resolves to a value.
Example
SELCET city, country =
CASE coid
WHEN 'DE' THEN 'Germany'
WHEN 'CH' THEN 'Swiss'
WHEN 'AT' THEN 'Austria'
ELSE 'not defined'
END
FROM map.city;
or if you have more then one argument to compare you can use this statement:
SELECT id, name,
CASE
WHEN(acde = 'IMP' and tin_uid <> '01234') THEN '01234'
WHEN(acde = 'EMP' and tin_uid <> '12345') THEN '12345'
WHEN(acde = 'SPE' and tin_uid <> '23456') THEN '23456'
WHEN(acde = 'VER' and tin_uid <> '34567') THEN '34567'
ELSE tin_uid
END tin
FROM db01.ze1020