sql
Keep only the latest record per listing
SQL & Data Modeling · Deduplication · medium · Original Uplift question · PostgreSQL · 10 min
The snapshots table has multiple rows per listing. Return only the most recent row per listing_id (by updated_at).
Fixture
snapshots
listing_id, price, updated_at
create table snapshots (listing_id int, price numeric, updated_at timestamp); insert into snapshots values (1,100,'2026-01-01'),(1,120,'2026-02-01'), (2,80,'2026-01-15'),(2,80,'2026-01-10');
Evaluation criteria
- Uses ROW_NUMBER partitioned by listing_id
- Orders by updated_at DESC to make rank 1 the latest
- Returns one row per listing
Detailed grading feedback appears after you submit.
Source
Original Uplift question based on a common interview pattern.
Your answer
You get one graded attempt here without an account. Create a free account for unlimited attempts, saved progress and community write-ups.
Answers stay hidden until you ask. Reveal the full model write-up when you are ready to compare.