Explaint the nvl2 function

Showing Answers 1 - 13 of 13 Answers

G Suresh Babu

  • Jul 26th, 2006
 

Sybtax:- - nvl2(expr1,expr2,expr3)In nvl2 if expr1 evaluates to NULL then expr3 is returned and if it evaluates to some value it returns expr2.for e.g select nvl2(commission_pct,'SAL+COMM','SAL') from employees;if commission_pct is having null value then SAL will be displayed else SAL+COMM.

gouthami

  • Aug 15th, 2006
 

SYNTAX FOR NVL2(EXPR1,EXPR2,EXPR3);

NVL2

  Was this answer useful?  Yes

sundar

  • Oct 3rd, 2006
 

nvl2-- can take three arguments

by using this we can convert null to values

nvl(a,b,c)

if a is null it will display c

if a is not null it ll display b

  Was this answer useful?  Yes

Hi everybody,

This is new features in 9i,

NVL means select nvl(comm,0) from tablename;

we r selecting a column comm that contain null values then it will be give by o or any specific name that u want,

in NVL2 means select NVL2(comm,sal+comm,sal) frm tab_name,

if first exp is true it will give sal only otherwise it will give sal+comm.

Regards

Pawan Ahuja

  Was this answer useful?  Yes

sangeetha

  • Dec 20th, 2006
 

Eg;NVL(comm,null),it takes null value as zero

  Was this answer useful?  Yes

nvl2(exp1,exp2,exp3)
if exp1 is null it manipulate exp3,if exp1 is not null it manipulates exp2
eg:select ename,nvl2(comm,comm+sal,sal) net from emp;

  Was this answer useful?  Yes

nvl2 function is the upgraded form of nvl function.In nvl function we need to pass two parameters.i.e. nvl(interest_rate ,returned_value) if the value of interest_rate is null then the nvl function returns the value of second parameter 'returned_value'.In nvl2 function we need to pass three parameters .i.e. nvl2 (interest_rate,returned_value_if_not_null,returned_value_if_null)if the value of interest_rate is null then the nvl function returns the value of the third parameter 'returned_value_if_null' else it returns the value of the second parameter 'returned_value_if_not_null'.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions