COALESCE: Replace NULL Phone Numbers With Default

Basics
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_idphone
1555-0100
2NULL
3555-0199

Expected Output

user_idphone
1555-0100
2N/A
3555-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 BY order is checked by the grader.
  • Query type: Write a single read-only Standard SQL SELECT (or WITH ... SELECT) query.

Constraints & Evaluation Criteria

  • Return `user_id, phone` ordered by `user_id ASC`.

Hints

SQL
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)