Share of Daily Watch Time by Video Surface Across Feed and Reels
Last updated: November 29, 2026
Quick Overview
Given video watch sessions tagged with the surface they happened on (Feed, Reels, Watch tab, Stories), compute for each day each surface's watch minutes and its share of that day's total watch minutes.
Meta
November 29, 20260
0
0 solved
Given video watch sessions tagged with the surface they happened on (Feed, Reels, Watch tab, Stories), compute for each day each surface's watch minutes and its share of that day's total watch minutes.
Meta tracks how time spent shifts between surfaces as Reels grows, and a quick share-of-total question is a common screen opener. The interviewer is checking whether you can compute a group total with a window instead of a second aggregate join, and whether you keep the denominator at the right grain.
What the Interviewer Expects
- Aggregates sessions to day by surface first
- Uses SUM(...) OVER (PARTITION BY day) for the daily total without a self-join
- Casts to a decimal before dividing to avoid integer division
- Confirms the shares sum to 1 for each day
- Raises the question of sessions that cross midnight
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 show the day-over-day change in Reels' share in percentage points?
- How would you compute the same share per country while keeping the global share as a separate column?
- If a session spans midnight, how would you split its minutes across the two days?
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: video_watch_sessions(session_id, user_id, surface, started_at, watch_seconds). surface takes values like 'feed', 'reels', 'watch_tab', 'stories'. I will attribute a session to the d...
Approach
Aggregate to (ds, surface, watch_minutes). Then a window SUM(watch_minutes) OVER (PARTITION BY ds) gives the day's total on every row, and the share is a simple division. Because the window runs a...