GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL Plus
Go To First  |  Previous Question  |  Next Question 
 SQL Plus  |  Question 36 of 132    Print  
Display the records between two range I know the nvl function only allows the same data type(ie. number or char or date Nvl(comm, 0)), if commission is null then the text “Not Applicable” want to display, instead of blank space. How do I write the query

  
Total Answers and Comments: 3 Last Update: June 16, 2008   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Satyavani
 
you can use the decode function for the above requirement. Please find the query as below:  
 
select ename,decode(nvl(comm,0),0,'Not Applicable',comm) from scott.emp; 
 
Thanks, 
satyavani

Above answer was rated as good by the following members:
Sowmya Viswanath
July 27, 2005 17:50:09   #1  
Satyavani        

RE: Display the records between two range I know the nvl function only allows the same data type(ie. num...
you can use the decode function for the above requirement. Please find the query as below:

select ename decode(nvl(comm 0) 0 'Not Applicable' comm) from scott.emp;

Thanks
satyavani

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
December 20, 2007 02:01:23   #2  
ora.nachs Member Since: January 2007   Contribution: 9    

RE: Display the records between two range I know the nvl function only allows the same data type(ie. number or char or date Nvl(comm, 0)), if commission is null then the text “Not Applicable” want to display, instead of blank space. How do I write the que
SELECT NVL (To_Char(comm) 'Not Applicable') FROM emp
 
Is this answer useful? Yes | No
June 16, 2008 12:12:07   #3  
Dr. Codd Member Since: June 2008   Contribution: 2    

RE: Display the records between two range I know the nvl function only allows the same data type(ie. number or char or date Nvl(comm, 0)), if commission is null then the text “Not Applicable” want to display, instead of blank space. How do I write the que
If "comm" is zero then the above query will give wrong result.
Query should be

SELECT NVL (To_Char(comm) 'Not Applicable') FROM table_name;

 
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