Back to Practice
#0317

Join Orders to Customer Names

EasySQL15 min10 XP

Problem

Return order_id, customer name, and amount for orders with known 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, amount INTEGER); customers(customer_id INTEGER, name TEXT)

Examples

Example 1
Inputone order has unknown customer_id 3
Outputonly orders 10 and 11

INNER JOIN keeps rows with matching customer records.

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
Inputone order has unknown customer_id 3
Expected[[10,"Asha",50],[11,"Ben",30]]

INNER JOIN keeps rows with matching customer records.

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