Wednesday, 30 March 2011

SQL ISNULL

Table Sales_Data
store_nameSales
Store A300
Store BNULL
 
The following SQL,
SELECT SUM(ISNULL(Sales,100)) FROM Sales_Data;

Table Sales_Data

store_nameSales
Store A300
Store B100


returns 400. This is because NULL has been replaced by 100 via the ISNULL function.

No comments:

Post a Comment