Customers Who Have Never Placed an Order
Preview mode. Log in to edit, run, submit, and save progress.
Medium
Customers Who Have Never Placed an Order
You are given two tables: Customers and CustomerOrders. Write a SQL query to find all customers who have never placed any order. Return the customer id, name, and country, ordered by id. Table: Customers
| Column Name | Type | Description |
|---|---|---|
| id | INT | Primary key |
| name | VARCHAR | Customer name |
| country | VARCHAR | Customer country |
Table: CustomerOrders
| Column Name | Type | Description |
|---|---|---|
| id | INT | Primary key |
| customer_id | INT | References Customers.id |
| amount | DECIMAL | Order amount |
| order_date | DATE | Date of order |
Examples
Example 1
Alice (id=1) and Carol (id=3) have orders. Bob and Dave have no orders and are returned.
Approach hint
Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
query.sql