Interview Questions/SQL/Customers Who Have Never Placed an Order

Customers Who Have Never Placed an Order

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Customers Who Have Never Placed an Order

You are given two tables: Customers and CustomerOrders. Write a SQL query to find all customers who have never placed any order. Return the customer id, name, and country, ordered by id. Table: Customers

Column NameTypeDescription
idINTPrimary key
nameVARCHARCustomer name
countryVARCHARCustomer country

Table: CustomerOrders

Column NameTypeDescription
idINTPrimary key
customer_idINTReferences Customers.id
amountDECIMALOrder amount
order_dateDATEDate of order

Examples

Example 1

Alice (id=1) and Carol (id=3) have orders. Bob and Dave have no orders and are returned.

Approach hint

Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

query.sql