SQL NVL and NVL2 Functions

NVL and NVL2 Functions


NVL() and NVL2() :- These functions are used to treat the null value.

NVL():- This function is used when we want to put any value in place of null value in column.

Syntax:- nvl(column_name,value)

Example:- select empno,ename,job,sal,nvl(comm,10) from emp;

This will show value 10 in place of null value in comm column

NVL2():- This function is used when we want to put some value in place of null values and want to put some different value in place of not null values.

Syntax:- nvl2(column_name,value1,value2)

Example:-  select empno,ename,job,sal,nvl2(comm,10,20) from emp;

This will show value 10 where comm column have not null values and will show 20 where comm column has null value

No comments:

Post a Comment