COALESCE Expression Examples | VantageCloud Lake - COALESCE Expression Examples - 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

Example: Querying for a Phone Number

The following example returns the home phone number of the named individual (if present), or office phone if HomePhone is null, or MessageService if present and both home and office phone values are null. Returns NULL if all three values are null.

SELECT Name, COALESCE (HomePhone, OfficePhone, MessageService) 
FROM PhoneDir;

Example: Using COALESCE with an Arithmetic Operator

The following example uses COALESCE with an arithmetic operator.

SELECT COALESCE(Boxes,0) * 100
FROM Shipments;

Example: Using COALESCE with an Comparison Operator

The following example uses COALESCE with a comparison operator.

SELECT Name
FROM Directory
WHERE Organization <> COALESCE (Level1, Level2, Level3);