Statement
easy
Customers without orders
Return the customers who have no orders.
Result columns: `id`, `name`.
Sort by `id` ascending. Each customer must appear at most once.
SQL · PostgreSQL
Schema
CREATE TABLE customers (
id integer PRIMARY KEY,
name text NOT NULL
);
CREATE TABLE orders (
id integer PRIMARY KEY,
customer_id integer NOT NULL REFERENCES customers(id),
total integer NOT NULL
);
Data
INSERT INTO customers (id, name) VALUES
(1, 'Анна'),
(2, 'Борис'),
(3, 'Вера'),
(4, 'Глеб'),
(5, 'Дина');
INSERT INTO orders (id, customer_id, total) VALUES
(10, 1, 5000),
(11, 1, 2000),
(12, 3, 7000),
(13, 5, 1000);
AI mentor
The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.
Log in and ask
Hints
1 of 3 unlocked · attempts: 0
Hint 1
You need rows from `customers` that have no matching row in `orders`. Start with
a join that keeps customers even when no order matches.
Hint 2 — unlocks after 1 attempt
Hint 3 — unlocks after 3 attempts