GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  General
Go To First  |  Previous Question  |  Next Question 
 General  |  Question 201 of 211    Print  
explaint the nvl2 function

  
Total Answers and Comments: 7 Last Update: June 16, 2008     Asked by: senthil 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: G Suresh Babu
 
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.

Above answer was rated as good by the following members:
smahajan161983
July 26, 2006 10:47:23   #1  
G Suresh Babu        

RE: explaint the nvl2 function
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.
 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
August 15, 2006 09:45:56   #2  
gouthami        

RE: explaint the nvl2 function

SYNTAX FOR NVL2(EXPR1 EXPR2 EXPR3);

NVL2


 
Is this answer useful? Yes | No
October 03, 2006 10:27:43   #3  
sundar        

RE: explaint the nvl2 function

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


 
Is this answer useful? Yes | No
October 05, 2006 06:07:40   #4  
PAWANAHUJAHUJA Member Since: October 2006   Contribution: 6    

RE: explaint the nvl2 function

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


 
Is this answer useful? Yes | No
December 20, 2006 12:55:52   #5  
sangeetha        

RE: explaint the nvl2 function

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


 
Is this answer useful? Yes | No
June 13, 2008 09:54:47   #6  
thumunagamani Member Since: June 2008   Contribution: 1    

RE: explaint the nvl2 function
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;

 
Is this answer useful? Yes | No
June 16, 2008 03:48:16   #7  
nandk.sharma Member Since: June 2008   Contribution: 10    

RE: explaint the nvl2 function
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'.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape