All pages
Powered by GitBook
1 of 1

Loading...

NVL2

Return values based on NULL status. This function returns the second argument if the first is not NULL, and the third argument if the first is NULL.

Syntax

NVL2(expr1,expr2,expr3)

Description

The NVL2 function returns a value based on whether a specified expression is NULL or not. If expr1 is not NULL, then NVL2 returns expr2. If expr1 is NULL, then NVL2 returns expr3.

Examples

See Also

This page is licensed: CC BY-SA / Gnu FDL

SELECT NVL2(NULL,1,2);
+----------------+
| NVL2(NULL,1,2) |
+----------------+
|              2 |
+----------------+

SELECT NVL2('x',1,2);
+---------------+
| NVL2('x',1,2) |
+---------------+
|             1 |
+---------------+
IFNULL (or NVL)