PostgreSQL

Aggregate Functions

The COALESCE function returns the first NOT-NULL value in a list.

Syntax

SELECT COALESCE(<list>);

or

SELECT COALESCE(<column>, <null-value-replacement>) 
FROM <table>;

Example #1

SELECT COALESCE(null, null, 1);
The first not null value in the list is 1.
Coalesce
1

Example #2

SELECT COALESCE(name, 'name not provided') 
FROM Company;
No name values in this table are NULL.
Name
Walmart
Disney
PayPal
Blackberry