COALESCE Function SQL

What is COALESCE Function in SQL

The SQL coalesce function will gives the first non-null string.


Syntax: coalesce (strng1, string2, string3 … stringn)
Ex:

select coalesce('a','b','c'), coalesce(null,'a',null,'b') from dual;
coalesce('a','b','c')
----------------------
a
 coalesce(null,'a',null,'b')
--------------------------
a

output on tool

COALESCE in SQL
COALESCE in SQL

Technical Details

Works in:SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse

Greast function

Leave a Reply