Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
SQL Server 119
#SQLServer 88
Oracle 70
#SQL SERVER 35
BRH 31
SQL Server 2012 29
denali 23
#TSQL 19
TSQL 19
C# 15

Archive · View All
October 2011 31
November 2011 30
September 2011 30
August 2011 18
December 2011 15
July 2011 13
June 2011 8
May 2012 4
April 2012 3
January 2010 3

Day 13: NVL2 function in Oracle

Sep 26 2011 11:46PM by Niladri Biswas   

Let Us Learn Oracle - Part 13 of N [ NVL2 function in Oracle ]

Source table: tblPlayers

Purpose: It is an extended version of NVL. It substitute a value when a null value is encountered as well as a non null value is encountered.

Syntax: NVL2( ColumnName, ReplaceValue_If_Not_Null,ReplaceValue_If_Null )

For the sake of illustration we have inserted one record where the Fee PerMatch is null.

Insert into tblplayers(PLAYERID,PLAYERFIRSTNAME,PLAYERLASTNAME,BELONGSTO,DOB,FEEPERMATCH)  Values(11,'P','Chopra','India',To_Date('14/02/1998','DD/MM/YYYY'),Null);

Now run the query


SQL> Select  PLAYERID,Concat(PLAYERFIRSTNAME,Concat(' ' , PLAYERLASTNAME)) PlayerName,NVL2(FeePerMatch,FeePerMatch,600) From tblplayers Order By PLAYERID;

  PLAYERID PLAYERNAME            NVL2(FEEPERMATCH,FEEPERMATCH,600)
---------- --------------------- ---------------------------------
         1 A Raman                                            2000
         2 B Kadir                                            1000
         3 C Nadir                                            3000
         4 D Das                                               500
         5 E Punchkar                                        12000
         6 F Fateman                                         22000
         7 G Gajani                                            999
         8 H Hariharan                                        7000
         9 I Ikat                                             5999
        10 J Jwar                                             7900
        11 P Chopra                                            600

11 rows selected.

We can make out that for PlayerId 11, the value for FeePerMatch has been replaced by 600.But for others it is 600

In Sql Server, we implement this functionality by using Coalesce.

Select 
	PLAYERID
	,Concat(PLAYERFIRSTNAME,Concat(' ' , PLAYERLASTNAME)) PlayerName	 
	,Coalesce(FeePerMatch,FeePerMatch,600)
From tblplayers Order By PLAYERID;

Thanks for reading.

Tags: #SQLServer, SQL Server, Oracle,


Niladri Biswas
7 · 21% · 6710
2 Readers Liked this
Ashraf Liked this on 10/14/2011 9:03:00 AM
Profile
Guru Samy Liked this on 8/1/2012 2:05:00 AM
Profile · Blog
2
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Day 13: NVL2 function in Oracle" rated 5 out of 5 by 2 readers
Day 13: NVL2 function in Oracle , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]