SQL CASE Expression
From Logic Wiki
Revision as of 13:32, 12 August 2014 by Macrop (Talk) (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...")
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