In this article, we will learn how to use the NULL Functions in SQL.

The following are the commonly used SQL NULL Functions.

FunctionDescription
ISNULL()It returns the specified value IF the expression is NULL, otherwise returns the expression.

SELECT ISNULL(EmpName, '-') AS EmpName FROM tblEmployees;

Output:

COALESCE()It returns the first non-null value in a list.

SELECT COALESCE(NULL, NULL, 'thecodehubs.com', NULL, 'thecodehubs');

Output: thecodehubs.com

NULLIF()It returns NULL if two expressions are equal otherwise, it returns the first expression.

SELECT NULLIF('thecodehubs', 'thecodehubs');

Output: NULL

 

Also, check How To Use Aggregate Functions In SQL

Subscribe

Select Categories