Difference between revisions of "SQL CASE Expression"
From Logic Wiki
(Created page with "Category:SQL Evaluates a list of conditions and returns one of multiple possible result expressions. The CASE expression has two formats: === Simple CASE expression === T...") |
m (1 revision imported) |
(No difference)
| |
Latest revision as of 14:27, 9 May 2016
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