COALESCE returns the first non-NULL value from a short list of columns or literals.

highlighted = computed this step

Input table

Start with contact rows where some email and phone cells are NULL.

Contacts\text{Contacts}
Contactscustomer_idemailphonec1email_aNULLc2NULLphone_bc3NULLNULL

Select query

Use COALESCE to choose email first, then phone, then a default label.

COALESCE email, phone, default\text{COALESCE email, phone, default}
SELECT COALESCE contact defaultselect customer_id,best_contactarity 2 rows 3Contactsarity 3 rows 3

Output table

Each row gets the first non-NULL contact value.

best contact\text{best contact}
Outputcustomer_idbest_contactc1email_ac2phone_bc3missing