Back to Practice
#0025
Customers With No Orders
EasySQL12 min10 XP
Problem
Write a SQL query that returns customer names for customers who have never placed an order.
Why This Matters
Anti-joins appear constantly in analytics: inactive users, missing payments, abandoned carts, and unmatched records.
Schema
customers(id, name) orders(id, customer_id, amount)
Examples
Example 1
Inputcustomers: (1, "Asha"), (2, "Ben"); orders: (1, 1, 500)
OutputBen
Asha has an order. Ben has no matching order row.
Constraints
- Return one column: name.
- Use customers as the base table.
- Customers may have many orders.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
One inactive customer
Input2 customers, 1 order for customer 1
Expectedcustomer 2 only
The left join creates NULL order fields for customers without orders.
Hidden Test Categories
No customers without ordersAll customers without ordersCustomer with multiple orders