IF
Purpose
The IF THEN ELSE
syntax is an alternate to CASE function.
Syntax
if::=
Usage Notes
- If the condition evaluates to true, the expression after
THEN
is returned. - If the condition evaluates to false, the expression after
ELSE
is returned, orNULL
if anELSE
expression is not defined. - If the condition evaluates to
NULL/UNKNOWN
, the expression returnsNULL
.
Examples
Result
NAME | AGE | LEGALITY |
Alice | 25 | adult |
Bob | 16 | underaged |
Charlie | NULL | NULL |
David | 34 | adult |