data // SQLPRODUCTION

COALESCE() for Ordered Fallback Values

Choose the first non-null value from multiple candidate fields.

sqlcoalescenullfallback
Context Pack →Open Workspace →
Trust & provenancePRODUCTION
Evidence tierPRODUCTIONOfficial sources0Other sources0Last verified2026-10-05

Evidence tier describes my hands-on relationship with the content. Official sources describe platform contracts/documentation. Production observations should not automatically be treated as official limits.

EvidencePRODUCTION
Difficultyfoundation
Verified2026-10-05
Use when

Consolidating fields across sources.

Applying a clear fallback chain without nested CASE statements.

SELECT
    SubscriberKey,
    COALESCE(PreferredName, FirstName, 'Cliente') AS DisplayName
FROM [Customer_Master]
Why it works

COALESCE returns the first non-null expression in the order provided.

Operational notes

Empty strings are not NULL. Normalize them first if your data sources mix both states.