Customers With No Orders

Easy SQLLEFT JOINSubquery

Problem

Schemas: Customer(id INT, name VARCHAR), Orders(id INT, customer_id INT). Return the names of customers who have NEVER placed an order.

Example 1 Input: Customers [Ada, Bo], Orders all from Ada Output: "Bo"

Constraints

Approach — Core Patterns

This is a Core Patterns problem. The idea: pick the data structure best matched to the constraints and solve it in one clean pass. Work through the reference code below line by line, then re-derive it yourself in the editor — that's how the pattern sticks.

Complexity: see the walkthrough below.

Solution code

SQL

SELECT c.name
FROM Customer c
LEFT JOIN Orders o ON o.customer_id = c.id
WHERE o.id IS NULL;

Practice it

Reading a solution isn't the same as being able to write it under pressure. Open this problem in the in-browser editor, hide the solution, and solve it from scratch — your code runs against real test cases instantly.

Solve Customers With No Orders interactively → ← All solutions