Daily Active Viewers and Watch Minutes by Device Type
Last updated: November 29, 2026
Quick Overview
From a playback events table, compute for each day and device type the number of active viewers, average watch minutes per active viewer, and the share of viewers who watched 30 minutes or more.
Tubi
November 29, 20260
0
0 solved
From a playback events table, compute for each day and device type the number of active viewers, average watch minutes per active viewer, and the share of viewers who watched 30 minutes or more.
Tubi is watched mostly on connected TVs, and total view time is the metric that drives ad inventory, so device-level engagement cuts are everyday work for its analysts. This screen checks clean aggregation in two stages and care about what counts as active.
What the Interviewer Expects
- Aggregates per viewer first, then per day and device, avoiding averages over raw events
- Filters to the event type that carries watch seconds
- Computes the 30-minute share with a conditional sum over viewers
- Explains how a viewer on two devices is counted
- Mentions time zone choice for the day boundary
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 compute the median minutes instead of the mean?
- How would you attribute a viewer who uses both a TV and a phone on the same day?
- How would you turn this into a 7-day rolling active viewer count?
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
Assume playback_events(viewer_id, event_ts, event_type, device_type, title_id, seconds_watched), where heartbeats carry seconds_watched since the last heartbeat. Active means at least one heartbea...
Approach
Average per viewer must be computed over viewers, not events, so first collapse to one row per (day, device, viewer) with total minutes, then aggregate that. The 30-minute share is a conditional count...