Customers who never ordered
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.
Output
customer_idcustomer_namequery.sql
DuckDB SQLRestoring your saved draft…
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
- 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.