CASE
The standard SQL CASE
expression has two forms:
The simple form searches each value
expression from left to right until it finds one that equals the given expression
and then returns the matching result
.
The searched form evaluates each Boolean condition
from left to right until one is true and returns the matching result
.
CASE ... WHEN
CASE ... WHEN
Syntax
Returns
The result
for the first value
found that matches the expression
is returned.
If no match is found, the result
from the ELSE
clause is returned if it exists; otherwise null
is returned.
Examples
SQL
Query result
CASE WHEN ...
CASE WHEN ...
Syntax
Returns
The result
corresponding to the first true condition
is returned.
If no conditions are true, the result
from the ELSE
clause is returned if it exists; otherwise null
is returned.
Examples
SQL
Query result
Last updated