Join orders to customer names
Return order_id, customers.name AS customer_name and amount for every order with a matching customer_id in customers. Keep separate orders even when their customer names or amounts are identical. Row order does not matter.
Difficulty: intermediate
Show hint
Use an INNER JOIN on customer_id. Qualify names that appear in both tables.
Tables and sample data
Each test starts with fresh tables. Result rows may be returned in any order. Column names and column order must match.
| customer_id (integer) | name (text) | city (text) |
|---|---|---|
| 1 | Asha | Kathmandu |
| 2 | Ben | London |
| order_id (integer) | customer_id (integer) | amount (numeric) | status (text) | region (text) |
|---|---|---|---|---|
| 10 | 1 | 50 | paid | East |
| 11 | 2 | 70 | paid | West |
| 12 | 1 | 30 | pending | East |
| order_id | customer_name | amount |
|---|---|---|
| 10 | Asha | 50 |
| 11 | Ben | 70 |
| 12 | Asha | 30 |