SQL CASE Expression
From Logic Wiki
Evaluates a list of conditions and returns one of multiple possible result expressions.
The CASE expression has two formats:
Simple CASE expression
The simple CASE expression compares an expression to a set of simple expressions to determine the result.
CASE input_expression
WHEN when_expression THEN result_expression [ ...n ]
[ ELSE else_result_expression ]
END
Searched CASE expression
The searched CASE expression evaluates a set of Boolean expressions to determine the result. Both formats support an optional ELSE argument.
CASE
WHEN Boolean_expression THEN result_expression [ ...n ]
[ ELSE else_result_expression ]
END