Skip to content
Onsite

Customers who never order

EasyP1Coding

Tables:

customers

ColumnType
idint (primary key)
nametext

orders

ColumnType
idint (primary key)
customer_idint (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

PostgreSQL
Run checks the 2 visible tests, Submit all 5.