Back to Practice
#0380

Preview Orphan Orders

MediumSQL24 min20 XP

Problem

Return order_id values whose customer_id does not exist in customers.

Why This Matters

SQL interviews usually test whether you can turn a business question into the right rows, grouping level, join type, and edge-case behavior.

Schema

orders(order_id INTEGER, customer_id INTEGER); customers(customer_id INTEGER)

Examples

Example 1
Inputorder 11 references customer 3
Outputorder 11

A missing dimension match becomes NULL after the LEFT JOIN.

Constraints

  • Return only the requested columns.
  • Use deterministic ORDER BY when multiple rows are returned.
  • Assume SQLite-compatible SQL unless the prompt states otherwise.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core SQL case
Inputorder 11 references customer 3
Expected[[11]]

A missing dimension match becomes NULL after the LEFT JOIN.

Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks