Look at the following "Products" table:
Suppose that the "UnitsOnOrder" column is optional, and may contain NULL values.
Look at the following SELECT statement:
In the example above, if any of the "UnitsOnOrder" values are NULL, the result will be NULL.
The SQL Server ISNULL()arrow-up-right function lets you return an alternative value when an expression is NULL:
Last updated 6 years ago
SELECT ProductName, UnitPrice * (UnitsInStock + UnitsOnOrder) FROM Products;
SELECT ProductName, UnitPrice * (UnitsInStock + ISNULL(UnitsOnOrder, 0)) FROM Products