Target
Foundations Track · Medium · 25 min
Top Purchase per Customer
Return each user_id with the purchase_id and amount of that user’s most expensive purchase. If two purchases tie on amount, keep the earlier purchased_at row...
Company labels are directional practice context, not official interview guidance.
Objective
Practice query basics through a Target-tagged business scenario.
Approach
Use this track to lock in clean query structure, basic filtering logic, and confidence with grouped output.
Company context
Company labels are directional practice context, not official interview guidance.
Return each user_id with the purchase_id and amount of that user’s most expensive purchase. If two purchases tie on amount, keep the earlier purchased_at row. Sort by user_id.
purchases
| purchase_id | user_id | amount | purchased_at |
|---|---|---|---|
| 1 | 10 | 60 | 2024-03-01 |
| 2 | 10 | 90 | 2024-03-04 |
| 3 | 10 | 90 | 2024-03-06 |
| 4 | 11 | 40 | 2024-03-02 |
| 5 | 11 | 80 | 2024-03-05 |
| 6 | 12 | 30 | 2024-03-03 |
SQL workspace
Run queries against the protected question data, then submit once the result shape looks right.
Sign in to run SQL
Create a free account or sign in before running queries against protected question data.