SQLSQL
#3

Handle Missing Customer Profile Data with COALESCE in SQL

Easy
Interview Question #3

Write a SQL query on `customers` that returns `customer_id`, `customer_name`, and a computed column `contact_channel`. If `email` is present, display `email`. If `email` is NULL, fallback to `phone_number`. If both are NULL, display 'Missing Contact'.

Input Table: customers
3 rows preview
customer_idcustomer_nameemailphone_number
1Aditi Sharmaaditi@gmail.com+919800000000
2Rahul VermaNULL+919711111111
3Sneha PatelNULLNULL
Expected Output Structure3 rows
customer_idcustomer_namecontact_channel
1Aditi Sharmaaditi@gmail.com
2Rahul Verma+919711111111
3Sneha PatelMissing Contact
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us