Find Customers Missing from New Table

SQL coding challenge · Difficulty: easy · +100 XP

Problem

After a database migration, your tech team suspects some customers were lost in the transfer. Find every customer in the old table that is missing from the new table.

Tables

Table: old_customers

| id | name | city |
| --- | --- | --- |
| 1 | Alice | Madrid |
| 2 | Bob | Paris |
| 3 | Carol | Lisbon |
| 4 | David | Rome |
| 5 | Emma | Berlin |

Table: new_customers

| id | name | city |
| --- | --- | --- |
| 1 | Alice | Madrid |
| 3 | Carol | Lisbon |
| 5 | Emma | Berlin |
| 6 | Frank | Oslo |
| 7 | Grace | Vienna |

Expected Output

| id | name | city |
| --- | --- | --- |
| 2 | Bob | Paris |
| 4 | David | Rome |
  • Return: id, name, email (from old_customers only, no match in new_customers)
  • Sort by id ascending
  • Hint: LEFT JOIN old_customers to new_customers + filter WHERE new.id IS NULL

Solve this challenge on PySpark.in