Find Play Store Buyers With Three Straight Months of Rising Spend

Last updated: November 29, 2026

Quick Overview

From a Google Play purchases table, return users whose net monthly spend increased strictly for three consecutive calendar months.

Google
Data Manipulation (SQL/Python)
Data Scientist
Google
November 29, 2026
Data Scientist
Phone Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


From a Google Play purchases table, return users whose net monthly spend increased strictly for three consecutive calendar months.

Play monetization analysts look for growing spenders to understand what drives engagement with paid content. The interviewer checks monthly aggregation, LAG usage, the consecutive-month requirement, and refund handling.

What the Interviewer Expects
  • Aggregate to user-month spend, excluding refunds
  • Use LAG to get prior months' spend and month values
  • Require calendar-consecutive months, not just consecutive rows
  • Apply strict increase conditions
  • Return distinct users
Key Topics to Cover
Window functions
LAG
Monthly aggregation
Gaps in time series
Refund handling
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you return the longest growth streak per user?
  • What if a month with zero spend should count as a drop?
  • How would you handle multiple currencies?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

play_purchases(user_id, purchase_ts, amount_usd, is_refunded). "Three consecutive months of rising spend" here means months M-2, M-1, M with spend(M-2) < spend(M-1) < spend(M), all calendar-consecut...

Approach

Aggregate to user-month, then for each row fetch the previous two rows' month and spend with LAG. Keep rows where the previous rows are exactly one and two months earlier and spend increases strictl...


Submit Your Answer
Markdown supported