Oracle NVL2 Function

Share on:

Oracle NVL2 Function:

NVL2() function is an extend version of the NVL() function with different options based on whether a NULL value exists.

Oracle NVL2() function allow three parameters. If the first parameter is not null, then it returns the second parameter. In case the second parameter is null, then it returns the third parameter.

  • Syntax of the NVL2() function:
1NVL2(elm1, elm2,elm3)

Example 1: Here in this example we are checking the first argument, if the first argument is not null, it will return second argument.

1select nvl2(1,'vikas','pandey') from dual;

Preview Example 2: Here in this example we are checking the first argument, if the first argument is null, it will return third argument.

1select nvl2(null,'vikas','pandey') from dual;

Preview

You might also like: