Flag Day-over-Day Drops in Instagram Stories Posts by Country
Last updated: November 29, 2026
Quick Overview
Compute daily Instagram Stories post counts per country and flag any day where the count fell more than 30% versus the prior day, ignoring countries too small to be meaningful. Also show the same comparison against the same weekday one week earlier.
Meta
November 29, 20260
0
0 solved
Compute daily Instagram Stories post counts per country and flag any day where the count fell more than 30% versus the prior day, ignoring countries too small to be meaningful. Also show the same comparison against the same weekday one week earlier.
Typical of Meta's metric monitoring questions, where a data scientist on Instagram owns alerting on core creation metrics. The interviewer checks LAG over a dense daily series and whether you think about weekly seasonality and noise floors before alerting.
What the Interviewer Expects
- Aggregate to country-day and densify missing days to zero
- Use LAG(1) and LAG(7) over the dense series
- Apply a minimum-volume threshold on the baseline
- Guard against division by zero
- Explain why week-over-week is often the better alert
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 reduce false alarms on holidays?
- What if a country's logging broke and counts went to zero?
- How would you turn the threshold into a statistical test?
- How would you rank which flags to look at first?
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
stories_posts(story_id, author_id, country, created_at) with UTC timestamps. I will bucket by UTC date unless asked for local dates. I need a calendar(ds) table to fill zero days, because a countr...
Approach
Count posts per country and day, cross join countries to the calendar and coalesce, then take LAG(1) and LAG(7) over each country's series. A drop is (prev - cur) / prev > 0.3. Day-over-day is noisy...