Same-Weekday Week-over-Week Change in Marketplace Listings
Last updated: November 29, 2026
Quick Overview
From a table of Marketplace listings, compute daily new listings per country and the percent change versus the same weekday one week earlier. Days with zero listings must still count as data points.
Meta
November 29, 20260
0
0 solved
From a table of Marketplace listings, compute daily new listings per country and the percent change versus the same weekday one week earlier. Days with zero listings must still count as data points.
Marketplace volume has a strong weekly cycle, so Meta analysts compare against the same weekday rather than yesterday. The interviewer wants to see LAG used correctly and, crucially, whether you notice that LAG counts rows rather than days when some days are missing.
What the Interviewer Expects
- Aggregates raw listings to country by day before applying window functions
- Builds a dense country by date grid so LAG(x, 7) really means seven days back
- Uses LAG with an offset of 7 partitioned by country
- Guards the division with NULLIF to avoid dividing by zero
- Explains why day-over-day comparisons mislead for weekly-seasonal metrics
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 instead compare against the average of the same weekday over the prior four weeks?
- How would you flag countries where the week-over-week drop exceeds 30 percent for three days in a row?
- How would timezone choice change the per-country daily counts?
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: listings(listing_id, seller_id, country, created_at). One row per new listing. I would ask whether created_at is UTC or local time; for a per-country daily view, local date is more honest, ...
Approach
- Aggregate to
(country, ds, listings). - Build a date spine from the min to max date and cross join it with the distinct countries so every country has every day.
- Left join the counts onto the...