CASE <test-expr>
WHEN <value-expr> THEN <result-expr>
[ WHEN ... ]
[ ELSE <default-expr> ]
END
If no match is found, and a default-expr
is present, it will return the value of that expression, otherwise it will return null.
XTDB provides a rich standard library of predicates and functions:
The following control structures are available in XTDB:
CASE
CASE
takes two forms:
With a test-expr
, CASE
tests the result of the test-expr
against each of the value-expr`s until a match is found - it then returns the value of the corresponding `result-expr
.
CASE <test-expr>
WHEN <value-expr> THEN <result-expr>
[ WHEN ... ]
[ ELSE <default-expr> ]
END
If no match is found, and a default-expr
is present, it will return the value of that expression, otherwise it will return null.
With a series of predicates, CASE
checks the value of each predicate
expression in turn, until one is true - it then returns the value of the corresponding result-expr
.
CASE
WHEN <predicate> THEN <result-expr>
[ WHEN ... ]
[ ELSE <default-expr> ]
END
If none of the predicates return true, and a default-expr
is present, it will return the value of that expression, otherwise it will return null.
COALESCE
/ NULLIF
COALESCE
returns the first non-null value of its arguments:
COALESCE(<expr>, ...)
NULLIF
returns null if expr1
equals expr2
; otherwise it returns the value of expr1
.
NULLIF(<expr1>, <expr2>)