Interview practice question
Sales by sales rep territory at the time of sale
Data Analyst · SQL for Analytics · Experienced
Sales reps change territories over time. How do you report sales by the territory the rep belonged to at the time of each sale?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Type 2 history table with valid_from/valid_to.
- Join on rep and sale_date between valid dates.
- Handle open-ended current rows.
- Check no overlaps/gaps.
- Compare with current-territory view.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.