Rank Google Ads Advertisers by Largest Week-Over-Week Spend Drop
Last updated: November 29, 2026
Quick Overview
Using daily ad spend per advertiser, compare last complete week to the week before and return the 50 advertisers with the largest absolute spend drop, counting a missing week as zero spend.
0
0
0 solved
Using daily ad spend per advertiser, compare last complete week to the week before and return the 50 advertisers with the largest absolute spend drop, counting a missing week as zero spend.
A Google Ads sales analytics scenario where account teams want an early warning list of advertisers pulling back. The interviewer checks complete-week boundaries, the zero-fill for advertisers who stopped entirely, and LAG used on a densified grid instead of on sparse data.
What the Interviewer Expects
- Restrict to complete weeks with a consistent week start
- Densify advertiser by week so a fully paused advertiser appears with zero spend
- Use LAG over the dense grid, not over sparse rows
- Rank by absolute change and also report percentage change
- Filter out tiny accounts to keep the list actionable
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you adjust for seasonality such as Black Friday weeks?
- Should new advertisers who had no prior week appear? Why or why not?
- How would you turn this into a daily alert without noisy false positives?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
ad_spend_daily(advertiser_id, spend_date, cost_micros), sparse: no row on days with no spend. Spend is in micros, so I divide by one million. Weeks start Monday. An advertiser who spent 5000 two wee...
Approach
Aggregate to weekly spend for the two most recent complete weeks. Build a grid of every advertiser seen in that period crossed with both weeks, left join the weekly spend and fill gaps with 0. LAG ove...