Net and Gross Revenue Retention for Advertiser Quarterly Cohorts

Last updated: November 29, 2026

Quick Overview

Group Meta advertisers by the quarter of their first spend and, for each later quarter, compute net revenue retention (cohort spend divided by the cohort's first-quarter spend) and gross revenue retention (each advertiser's spend capped at its own first-quarter spend).

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


Group Meta advertisers by the quarter of their first spend and, for each later quarter, compute net revenue retention (cohort spend divided by the cohort's first-quarter spend) and gross revenue retention (each advertiser's spend capped at its own first-quarter spend).

Revenue retention is how Meta's monetization teams separate growth from existing advertisers from new acquisition. Onsite interviewers use it to see whether you can build a cohort baseline per entity, compute two related metrics in one query, and explain why net can exceed 100 percent while gross cannot.

What the Interviewer Expects
  • Define cohort as first quarter with positive spend
  • Compute a per-advertiser baseline and join it back
  • Cap per-advertiser spend at baseline for gross retention
  • Include advertisers with zero spend in later quarters
  • Explain the difference between net, gross and logo retention
Key Topics to Cover
net revenue retention
gross revenue retention
cohort baseline
LEAST
quarter offsets
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 present this to a sales leader who wants one number?
  • Why can a cohort's NRR exceed 100 percent while logo retention falls?
  • How would currency fluctuations affect this metric for non-USD advertisers?
  • How would you handle advertiser account merges?
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

ad_spend(advertiser_id, ds, spend_usd) in USD. Cohort quarter is the first quarter with positive total spend. Quarter offset k = 0 is the first quarter. The latest quarter may be partial and should ...

Approach
  1. q_spend: total spend per advertiser and quarter. 2. base: first positive quarter per advertiser and its spend. 3. Join every later quarter to the baseline, computing k and `LEAST(spend, base_...

Submit Your Answer
Markdown supported