Advanced Joins: Customers With No Orders

SQL coding challenge · Difficulty: easy · +50 XP

Problem

The reactivation team targets customers who exist in the system but have never placed an order. Find them using LEFT JOIN + IS NULL.

Tables

Table: Customers

| customer_id | name | city |
| --- | --- | --- |
| 1 | Atul | Delhi |
| 2 | Prince | Mumbai |
| 3 | Mohit | Bangalore |
| 4 | Rahul | Chennai |

Table: Orders

| order_id | customer_id | order_date |
| --- | --- | --- |
| 101 | 1 | 2024-05-01 |
| 102 | 1 | 2024-05-05 |
| 103 | 2 | 2024-05-03 |
| 104 | 3 | 2024-05-07 |

Table: Payments

| payment_id | order_id | amount |
| --- | --- | --- |
| 201 | 101 | 2500.00 |
| 202 | 102 | 1250.00 |
| 203 | 103 | 3000.00 |
| 204 | 104 | 1750.00 |
| 205 | 106 | 2200.00 |

Expected Output

| customer_id | name | city |
| --- | --- | --- |
| 4 | Rahul | Chennai |
  • Return: customer_id, name, email
  • Must use LEFT JOIN + IS NULL technique
  • Sort by customer_id ascending

Solve this challenge on PySpark.in