Wednesday, 30 March 2011

SQL IFNull

Table Sales_Data
store_nameSales
Store A300
Store BNULL
 
The following SQL,
 
SELECT SUM(IFNULL(Sales,100)) FROM Sales_Data;
returns 400. This is because NULL has been replaced by 100 via the IFNULL function.

No comments:

Post a Comment