Wednesday, 30 March 2011

SQl NVL

Table Sales_Data
store_nameSales
Store A300
Store BNULL
Store C150
 
The following SQL,
SELECT SUM(NVL(Sales,100)) FROM Sales_Data;
returns 550. This is because NULL has been replaced by 100 via the ISNULL function, hence the sum of the 3 rows is 300 + 100 + 150 = 550.

No comments:

Post a Comment