IsNull:
Return the specified value IF the expression is NULL, otherwise return the expression:
SELECT ISNULL(NULL, 'W3Schools.com');
In SQL Server, the ISNULL( ) function is used to replace NULL value with another value.
COALESCE:
Return the first non-null value in a list:
SELECT COALESCE(NULL, NULL, NULL, 'W3Schools.com', NULL, 'Example.com');
Output:W3Schools.com
Return the specified value IF the expression is NULL, otherwise return the expression:
SELECT ISNULL(NULL, 'W3Schools.com');
In SQL Server, the ISNULL( ) function is used to replace NULL value with another value.
| Store_Name | Sales |
| Store A | 300 |
| Store B | NULL |
SELECT SUM (ISNULL(Sales,100)) FROM Sales_Data;
returns the following result:
| SUM (ISNULL(Sales,100)) |
| 400 |
COALESCE:
Return the first non-null value in a list:
SELECT COALESCE(NULL, NULL, NULL, 'W3Schools.com', NULL, 'Example.com');
Output:W3Schools.com
No comments:
Post a Comment