Gatekeeper (6/14/2011)
Alexey Voronin (6/14/2011)
What's this COALESCE(SUM(SalesTestData.SaleQty),0) ?You do not know ISNULL ?
ISNULL(SUM(SalesTestData.SaleQty),0)
They are interchangeable. Both are the same thing except COALESCE() allows for more than one evaluation.
Actually, they're not interchangeable at the semantic level. COALESCE is slower than ISNULL (although it takes a substantial number of rows to tell). COALESCE is in the ANSI standard where ISNULL is proprietary. COALESCE can change the datatype of the result based on which non-null element is selected (which can cause a major performance problem, BTW). ISNULL will keep the datatype of the return the same as the datatype of the first operand. COALESCE takes more keystrokes to type than ISNULL (BIG selling point for me. :-P)
Heh... other than that, they're interchangeable when two operands are necessary. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.