Back to problems

Write SQL for rolling frequency caps

SQL · Netflix · Hard

You maintain an ad-serving stack that limits how many impressions a single user may see from one campaign inside any trailing 7-day span. The clock is pinned: today is 2025-09-01, and the evaluation instant is t0 = 2025-09-01 12:00:00 UTC. Rules that hold throughout: An impression counts only if the calendar date of its ts lies inside its campaign's inclusive date range [start_date, end_date]. The trailing 7-day span evaluated at instant t collects impressions stamped in…

Checking your access…