COALESCE Expression Usage Notes - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530

A scalar_expression_n in the argument list may be evaluated twice: once as a search condition and again as a return value for that search condition.

Using a nondeterministic function, such as RANDOM, in a scalar_expression_n may have unexpected results, because if the first calculation of scalar_expression_n is not NULL, the second calculation of that scalar_expression_n, which is returned as the value of the COALESCE expression, may be NULL.

You can use a scalar subquery in a COALESCE expression. However, if you use a non-scalar subquery (a subquery that returns more than one row), a runtime error is returned.

The following restrictions apply to specific data types in a COALESCE expression.

Data Type Restrictions
BLOB A BLOB can only appear in the argument list when cast to BYTE or VARBYTE.
CLOB A CLOB can only appear in the argument list when cast to CHAR or VARCHAR.