Customers Who Have Never Placed an Order
SQL coding challenge · Difficulty: easy · Topic: Joins · +50 XP
Problem
The marketing team is launching a re-engagement campaign. They need a list of customers who have never placed a single order to send them a special discount.
Tables
Table: Customer
| customer_id | customer_name | city | | --- | --- | --- | | 1 | Krishna | Hyderabad | | 2 | Sudheer | Bangalore | | 3 | Atul | Pune | | 4 | Rahul | Hyderabad |
Table: Orders
| order_id | customer_id | order_date | amount | aspect | | --- | --- | --- | --- | --- | | 101 | 1 | 2024-05-01 | 2500.00 | Electronics | | 102 | 1 | 2024-05-03 | 1500.00 | Books | | 103 | 2 | 2024-05-05 | 3000.00 | Clothing | | 104 | 4 | 2024-05-07 | 1200.00 | Books | | 105 | 4 | 2024-05-10 | 2200.00 | Electronics |
Expected Output
| customer_id | customer_name | city | | --- | --- | --- | | 3 | Atul | Pune |
- Return:
customer_id,customer_name,city - Sort by
customer_idascending - Hint: Think LEFT JOIN — when there is no matching order, the order columns are NULL
Success Criteria
- Only customers with no orders at all appear.
- A customer with even one order is excluded.
- The rows match the Expected Output exactly, with no extras.
- Row order is not graded; the set of rows is.
Production Constraints
- Customers with zero orders must be identified, not silently dropped.
- An INNER JOIN cannot answer this question at all -- only a LEFT JOIN with a NULL check can.
Why This Matters
"Which rows exist on one side of a relationship but not the other" is a common data-quality and business question -- who never converted, which reference records are unused. It specifically requires an outer join, not an inner one, which is why the join type here is a deliberate part of the lesson.
What this SQL challenge teaches you
“Customers Who Have Never Placed an Order” is a easy-level SQL challenge focused on Joins. Working through it gives you hands-on practice with scenario:data_quality, LEFT JOIN, IS NULL, NULL Check — the kind of transformation you are asked to write in real data engineering work and in technical interviews. You can solve it directly in the browser: the dataset is pre-loaded, so you write the query or DataFrame code, run it, and compare your output against the expected result immediately.
Concepts covered
- scenario:data_quality
- LEFT JOIN
- IS NULL
- NULL Check
How to approach it
If you get stuck, work through these steps in order before looking at a full solution — each one narrows the problem down:
- You are looking for an absence. An inner join cannot show you one, because a customer with no orders has nothing to join to.
- A LEFT JOIN keeps every customer and puts NULL on the order side where nothing matched.
- Filter WHERE the order side IS NULL, or use NOT EXISTS. Both express 'no matching row'.
Where this comes up
Variations of this problem have been reported in interviews at Flipkart, Infosys, TCS. Interviewers use it to check whether you can express the logic cleanly and reason about correctness on edge cases such as ties, nulls and empty groups.
How to practise it on PySpark.in
Open the challenge, write your SQL query in the editor and press Run to execute it against the sample dataset. Submitting checks your output against every test case, including hidden ones, so you find out straight away whether your logic holds up. You can retry as often as you like, and each solved challenge adds to your XP.
Related SQL challenges
- Find Customers Missing from New Table
- Customers With at Least One Order
- Count Orders Per Customer Including Zero
- Total Amount Spent Per Customer (With Zero)
- Find Employees in the HR Department
- Count Employees Per Department
Helpful resources
Frequently asked questions
Do I need to install Spark or a database to solve this?
No. The SQL environment runs in your browser with the sample data already loaded, so there is nothing to install or configure.
Is this challenge free?
Yes - the problem, the sample dataset, the hints and unlimited test runs are free.
What level is it?
It is rated easy and covers Joins.