SQL
All Top 50 SQL Interview Questions#3
Handle Missing Customer Profile Data with COALESCE in SQL
EasyInterview 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_id | customer_name | phone_number | |
|---|---|---|---|
| 1 | Aditi Sharma | aditi@gmail.com | +919800000000 |
| 2 | Rahul Verma | NULL | +919711111111 |
| 3 | Sneha Patel | NULL | NULL |
Expected Output Structure3 rows
| customer_id | customer_name | contact_channel |
|---|---|---|
| 1 | Aditi Sharma | aditi@gmail.com |
| 2 | Rahul Verma | +919711111111 |
| 3 | Sneha Patel | Missing Contact |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.