| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|||||||
| Oracle Interview / Technical Questions Kindly solve an many as questions you can. It will sharpen your skills and those solutions will help others too. |
![]() |
|
|
LinkBack | Thread Tools | Rate Thread | Display Modes |
|
|
#1 (permalink) |
|
Senior Member
Join Date: Jan 2007
Age: 27
Posts: 283
Thanks: 0 Thanked 2 Times in 2 Posts Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 4
|
Sql - What does the following query do? SELECT SAL + NVL(COMM,0) FROM EMP;
Sql - What does the following query do? SELECT SAL + NVL(COMM,0) FROM EMP;
|
|
|
|
|
|
#2 (permalink) |
|
Senior Member
Join Date: Mar 2006
Age: 24
Posts: 343
Thanks: 3 Thanked 12 Times in 12 Posts Thanks: 3
Thanked 12 Times in 12 Posts
Rep Power: 8
|
Re: Sql - What does the following query do? SELECT SAL + NVL(COMM,0) FROM EMP;
NVL function is used to substitue a value when a null value present.
In this case, NVL(comm,0) replaces every null value with number 0. <column_value>+NULL sums to NULL. Hence for conviniece, as long as we are logically right, we are in this case trying to add 2 numbers, Hence we are using NVL(comm,0) so that the operation inturn wud be for null values in commission sal+0 which makes sense.
__________________
JSP,Oracle,SQL : http://mycodesnippetjsp.blogspot.com/ Complete List :http://www.blogger.com/profile/04567238067268200918 |
|
|
|
|
|
#4 (permalink) |
|
Super Moderator
Join Date: Feb 2006
Location: Hyderabad
Posts: 2,355
Thanks: 117 Thanked 241 Times in 198 Posts Thanks: 117
Thanked 241 Times in 198 Posts
Blog Entries: 4
Rep Power: 51
|
Re: Sql - What does the following query do? SELECT SAL + NVL(COMM,0) FROM EMP;
NVL function can be used if you want to handle null differently. Generally NVL function is used to replace 'null' value with some other value while querying data.
In the above usage nvl(comm,0) - if 'comm' column value is null, then 0 (zero) is returned. Otherwise, value in 'comm' column is returned. You can also replace the value of that 0 (zero) with any value as required. Ref links - Oracle/PLSQL: NVL Function How to use the nvl function in Oracle Similar - Oracle/PLSQL: NVL2 Function Mini-Tip #2 - NVL2() Oracle Functions Thanks, Krishna
__________________
Give 1 cup rice to a hungry Indian just by a mouse click. No money, no form filling, no hassle... Click here for the donation. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sql - What will be the output of the following query? SELECT DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' ); | radhika_btech | Oracle Interview / Technical Questions | 0 | 23-01-07 09:33 PM |
| Sql - What is diffrence between Co-related sub query and nested sub query?? | radhika_btech | Oracle Interview / Technical Questions | 0 | 23-01-07 09:28 PM |
| Sql - What is the output of the following query SELECT TRUNC(1234.5678,-2) FROM DUAL; | radhika_btech | Oracle Interview / Technical Questions | 0 | 23-01-07 09:27 PM |
| SQL SERVER 2000 QUESTIONS.... | LALIT KUMAR | VB / ASP.NET Technologies | 2 | 16-12-06 06:29 PM |