bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL Server COALESCE() Function

Concept visual

SQL Server COALESCE() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

Formula

Return the first non - null value in a list:

Select

COALESCE(NULL, NULL, NULL, 'W3Schools.com', NULL, 'Example.com');

Definition and Usage

Formula

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

Syntax

Coalesce(

val1, val2,...., val_n )

Parameter Values

Parameter

Description val1, val2, val_n Required. The values to test

Technical Details

Works in:

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

More Examples

Example

Formula

Return the first non - null value in a list:

Select

COALESCE(NULL, 1, 2, 'W3Schools.com');

Previous

❮ SQL Server Functions

Next

Previous

SQL Server CAST() Function

Next

SQL Server CONVERT() Function