Smallest Set of Advertisers That Make Up 80 Percent of Revenue
Last updated: November 29, 2026
Quick Overview
Given quarterly ad revenue per advertiser, return the smallest set of top advertisers whose combined revenue reaches at least 80 percent of total revenue, along with each one's cumulative share.
Meta
November 29, 20260
0
0 solved
Given quarterly ad revenue per advertiser, return the smallest set of top advertisers whose combined revenue reaches at least 80 percent of total revenue, along with each one's cumulative share.
Revenue concentration matters for Meta's ads business planning, and a Pareto cut is a classic cumulative-sum interview task. The interviewer wants a running sum over a global ordering and the subtle boundary condition that includes the advertiser who crosses 80 percent.
What the Interviewer Expects
- Orders advertisers by revenue descending with a deterministic tie-break
- Computes a running cumulative sum with an explicit ROWS frame
- Computes the grand total with an empty OVER()
- Includes the row that crosses the threshold by testing the cumulative sum before that row
- Reports the count of advertisers and their share of the advertiser base
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 compute this separately per region and compare concentration across regions?
- How would you express concentration with a single number, such as a Herfindahl index?
- If revenue is reported in many currencies, where in the query would you convert?
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
Table: advertiser_revenue_q(advertiser_id, quarter, revenue_usd). I will filter to one quarter. Revenue is already in USD and non-negative. Refund adjustments could make a few values zero; they will...
Approach
Sort advertisers by revenue descending. A running SUM gives the cumulative revenue at each row; SUM(...) OVER () gives the total. The advertiser that pushes the cumulative share past 80 percent mu...