N-th Most Recent Purchase per User and Its Change from the Previous Purchase
Asked at Coinbase · ML Fundamentals & Algorithms · Difficulty: Medium · Last asked Dec 19, 2025
An analytics team keeps every user action in one `events` table. They want, for each user, the purchase that sits `n` places back from that user's latest purchase, together with how much its amount changed compared with the purchase just before it. Write the SQL query that produces this report.
Loading the problem…
More Coinbase interview questions
- Design Coinbase Explore Real-Time Price Dashboard
- Design a Multi-Chain Crypto Ledger & Wallet History
- Design a Credit-Approval Risk Engine
- Baseline Classifier on a Messy Tabular Dataset
- Hiring Manager - Project Deep-Dive + AI Usage BQ
- Implement K-Means Clustering from Scratch