Customers Who Never Ordered
Problem statement
You are given two tables, customers and orders.
Return the customer_id and customer_name of every customer who has never placed an order.
Return the rows in ascending order by customer_id.
Table schema
MySQLPostgreSQLPandas
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
customers
| Column | Type | Nullable | Description |
|---|---|---|---|
| customer_idPK | Integer | No | Unique customer identifier. |
| customer_name | Text | No | Customer display name. |
orders
| Column | Type | Nullable | Description |
|---|---|---|---|
| order_idPK | Integer | No | Unique order identifier. |
| customer_id | Integer | No | Customer who placed the order. |
Foreign key: customer_id → customers(customer_id)
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| customer_id | Integer | No | — |
| customer_name | Text | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- Each
customers.customer_idis unique. - Each
orders.order_idis unique. - Every
orders.customer_idreferences an existing customer. - A customer may have zero, one, or many orders.
- Return each qualifying customer exactly once in ascending
customer_idorder.