Scalar FunctionsConditional Functions
coalesce
Returns the first non-empty value (not null and not empty string).
For each row,
arguments are evaluated left to right only until one yields the value; a later
argument is not evaluated for that row and raises no error. The picked value is
read as the result type, never converted: a number widens (a long to a real), and a
value of another type, such as a numeric dynamic beside a string argument, is null
with a warning; write tostring() to use its text. Coalesce does not move on to the
next argument for it. When every argument is empty, the last one is returned.
Syntax
coalesce(value)Parameters
Prop
Type
Returns: any
Examples
Example 1
print coalesce(long(null), 793)| print_0 (long) |
|---|
| 793 |
Example 2
print coalesce('', 'Valhalla')| print_0 (string) |
|---|
| Valhalla |
Example 3
print coalesce(dynamic(null), dynamic(42), 5)| print_0 (long) |
|---|
| 42 |