SQL Functions and Aggregation/Replace NULL with fallback value

Return the first non-NULL value in a list.

Section: Conditional, NULL, and Conversion Functions

Replace NULL with fallback value

sql
sql
SELECT COALESCE(phone, mobile_phone, 'N/A') AS preferred_phone
FROM contacts;
Explanation

COALESCE is portable and common across SQL engines.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Conditional, NULL, and Conversion Functions
Convert a value to NULL conditionally
Return NULL when two expressions are equal.
OpenIn sheetsqlsame section
Use CASE expression
Return different values based on conditions.
OpenIn sheetsqlsame section
Convert data types
Cast an expression to a different type.
OpenIn sheetsqlsame section
Concatenate strings
Join multiple strings into one value.
Get current date and timestamp
Return the current date and current timestamp.
Count distinct values
Count unique entries in a column.