Customers who never order
EasyP1Coding
Tables:
customers
| Column | Type |
|---|---|
| id | int (primary key) |
| name | text |
orders
| Column | Type |
|---|---|
| id | int (primary key) |
| customer_id | int (references customers.id) |
Write a query that returns the names of customers who have never placed an order. Return one column named customer.
Schema
CREATE TABLE customers ( id int PRIMARY KEY, name text NOT NULL ); CREATE TABLE orders ( id int PRIMARY KEY, customer_id int NOT NULL REFERENCES customers(id) );
Example 1
- Input
- customers: (1, 'Ann'), (2, 'Bob') orders: (10, 1)
- Output
- customer: Bob
Constraints
- PostgreSQL dialect.
- A customer can have many orders.
- Return rows in any order.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
PostgreSQL
Run checks the 2 visible tests, Submit all 5. ⌘Enter runs, ⌘⇧Enter submits.