CASE keyword
#
Syntax#
DescriptionCASE
goes through a set of conditions and returns a value corresponding to the
first condition met. Each new condition follows the WHEN condition THEN value
syntax. The user can define a return value when no condition is met using
ELSE
. If ELSE
is not defined and no conditions are met, then case returns
null
.
#
ExamplesAssume the following data
name | age |
---|---|
Tom | 4 |
Jerry | 19 |
Anna | 25 |
Jack | 8 |
CASE with ELSE
Result
name | case |
---|---|
Tom | minor |
Jerry | major |
Anna | major |
Jack | minor |
CASE without ELSE
Result
name | case |
---|---|
Tom | null |
Jerry | major |
Anna | major |
Jack | null |