The Address That Changed
A hard SQL interview practice problem on DataDriven. Write and execute real sql code with instant grading.
- Domain
- SQL
- Difficulty
- hard
- Seniority
- L5
Problem
We maintain a slowly changing dimension (Type 2) for customer addresses. Each customer_id can appear multiple times, once per address change. The current record is the one where last_name is NULL. Find each customer's current country and how many times they have moved (total records minus 1). Show customer_id, first_name, current country, and move count.
Summary
Addresses change. History must not be erased.
Practice This Problem
Solve this SQL problem with real code execution. DataDriven runs your SQL queries against a real database and grades it automatically.