Spending Velocity
A medium SQL interview practice problem on DataDriven. Write and execute real sql code with instant grading.
- Domain
- SQL
- Difficulty
- medium
- Seniority
- L5
Problem
A fraud model watches each customer's spending pace, so for every transaction we need a trailing total across that customer's seven most recent purchases up to and including it. Walk each customer's transactions from earliest to latest and return user_id, transaction_date, total_amount, and that trailing total.
Summary
Fraud hides in the pace, not the price. Watch each customer's last seven purchases roll forward.
Practice This Problem
Solve this SQL problem with real code execution. DataDriven runs your SQL queries against a real database and grades it automatically.