COALESCE() saves quite a lot of IF or CASE decision logic. : COALESCE « Data Convert Functions « SQL Server / T-SQL Tutorial






4>
5> CREATE TABLE #ProductPrices (
6> ProductName VarChar(25),
7> SuperSalePrice Money NULL,
8> SalePrice Money NULL,
9> ListPrice Money NULL)
10> GO
1>
2> SELECT ProductName, COALESCE(SuperSalePrice, SalePrice, ListPrice) AS CurrentPrice
3> FROM #ProductPrices
4> GO
ProductName               CurrentPrice
------------------------- ---------------------

(0 rows affected)
1>
2> drop table #ProductPrices;
3> GO








13.2.COALESCE
13.2.1.COALESCE is equivalent to a CASE expression that returns the first NOT NULL expression in a list of expressions.
13.2.2.Returning the First Non NULL Value in a List of Expressions
13.2.3.COALESCE() saves quite a lot of IF or CASE decision logic.
13.2.4.A SELECT statement that uses the COALESCE function
13.2.5.A SELECT statement that substitutes a different data type