The function SWITCH evaluate a list of expressions and returns the value of
the first expression that TRUE is. If there are no expression TRUE then it
returns NULL. This is not a standard function and exist for compatible with MS
Access.
SQL Syntax:
|
|
SWITCH( expression1,
value1, expression2,
value2, ...) |
Parameters:
|
|
expression
Any Boolean expression.
value
The return value if the expression is TRUE.
|
Return Type:
|
|
The same as the value. |
Examples:
SELECT switch( name = 'Peter' , 1, name = 'Steven', 2 )
see also:
CASE
SQL System Functions
IIF
IFNULL
|