NVL2 is a function which is used to deal with NULL values. NVL2 function examines the first expression. If the first expression is not NULL then NVL2 function returns the second expression. If the first expression is NULL then the third expression is returned. Syntax is NVL2(Commision sal*commision sal). Example below will clear all things-
Suppose we have a table which has fields-
Empno Ename Deptno sal Manager job hiredate and Commision. Commision field has NULL values. Now we want to replace null values with string 'NO Comm' and show Commision where it is then
Select Ename job sal NVL2(Commision sal*commision sal) Revised Salary from emp;
run it and check it.