Layout

Customers who never ordered

PROBLEM 7 / 24 · BASICAll problems ↗

Find customers with no order of any status. Return customer_id and customer_name. A customer with only a cancelled order is not included. Row order does not matter.

Outputcustomer_idcustomer_name

query.sql

DuckDB SQL

Restoring your saved draft…

⌘ / Ctrl + Enter to run

Run a query to see results.

Reveal solution & explanation
SELECT c.customer_id, c.customer_name FROM customers c WHERE NOT EXISTS (SELECT 1 FROM orders o WHERE o.customer_id = c.customer_id);

The question is no orders, not no completed orders. NOT EXISTS avoids accidental duplication and handles missing matches clearly.

Data & schema

customer_id
INTEGER · PK
customer_name
VARCHAR
country
VARCHAR
email
VARCHAR
signup_date
DATE
Table notes & relationships

Buyer accounts. Some buyers have no orders, and some email addresses are NULL.

Fictional teaching data. Money is USD cents; timestamps are UTC.