COALESCE

COALESCE returns the first non-null expression among its arguments.

Syntax

COALESCE (expression1, expression2, expression3…)

This is equivalent to:

CASE
	WHEN expression1 NOT NULL THEN expression1
	WHEN expression2 NOT NULL THEN expression2
	ELSE expression3
END

Remarks

TDV Server supports push of the COALESCE functional expression directly to the following data sources to take advantage of any indices that might yield a performance advantage: DB2, MySQL, Netezza, Oracle, SQL Server, Sybase, and Teradata.

Example

SELECT 
CAST (COALESCE (hourly_wage * 40 * 52, salary, commission * num_sales) AS money) 
FROM wages