BasicsCOALESCENULLGoogleAmazonMeta
Table
contacts(user_id INT, phone VARCHAR)
Task
From contacts(user_id, phone), return user_id and phone, replacing any NULL phone number with 'N/A', ordered by user_id ASC.
Why It Matters: COALESCE(col, fallback) replaces SQL NULLs cleanly so downstream BI reports and string concatenations never break.
Output columns: user_id, phone
Example
Input — contacts
| user_id | phone |
|---|---|
| 1 | 555-0100 |
| 2 | NULL |
| 3 | 555-0199 |
Expected Output
| user_id | phone |
|---|---|
| 1 | 555-0100 |
| 2 | N/A |
| 3 | 555-0199 |
Explanation: Any row with NULL phone number is replaced by the fallback string while existing numbers pass through unchanged.
Requirements
- Exact output columns:
user_id,phone - Row order: Exact
ORDER BYorder is checked by the grader. - Query type: Write a single read-only Standard SQL
SELECT(orWITH ... SELECT) query.
Constraints & Evaluation Criteria
- Return `user_id, phone` ordered by `user_id ASC`.
Hints
SQL⌘/Ctrl+Enter to Run · ⌘/Ctrl+Shift+Enter to Submit
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
contacts (3 rows)
Expected Output / Criteria
3 row(s): (1, 555-0100); (2, N/A); (3, 555-0199)