Search ⌘K
Target
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...

Foundations Track
Medium
25 min
query basics
filtering

Company labels are directional practice context, not official interview guidance.

Timer 00:00
Back to practice

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.

Prereq: query basics

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 INT
user_id INT
amount INT
purchased_at DATE
purchase_iduser_idamountpurchased_at
110602024-03-01
210902024-03-04
310902024-03-06
411402024-03-02
511802024-03-05
612302024-03-03
Editor
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.