NVL2

functionsupportedCore SQL functions

docs.snowflake.com ↗

Conditional expression functions

Returns values depending on whether the first input is NULL: - If expr1 is NOT NULL, then NVL2 returns expr2. - If expr1 is NULL, then NVL2 returns expr3.

Syntax

NVL2( <expr1> , <expr2> , <expr3> )

Parameters

NameRequiredDescription
expr1requiredThe expression to be checked to see whether it is NULL.
expr2requiredIf expr1 is not NULL, this expression will be evaluated and its value will be returned.
expr3requiredIf expr1 is NULL, this expression will be evaluated and its value will be returned.

Usage notes

Collation details

- The collation specification for expr1 is ignored because all that matters about this expression is whether it is NULL or not. - The collation specifications for expr2 and expr3 must be compatible. - The value returned from the function is the highest-precedence collation of expr2 and expr3.