Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Average Reels Watch Time with NULLs

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Average Reels Watch Time with NULLs. Start with the requirements and the one table on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

A Meta Product Growth Analyst is reviewing Instagram Reels engagement as part of the AARRR funnel. Some time_spent_seconds values are NULL because the client failed to log watch time for a subset of sessions.

Write a SQL query to calculate the average time spent on Reels by surface, while handling NULL values correctly.

Requirements

  1. Return surface and the average of time_spent_seconds as avg_time_spent_seconds.
  2. Exclude NULL watch-time values from the average calculation.
  3. Only include rows where event_date is '2024-06-01'.
  4. Order the result by avg_time_spent_seconds in descending order.

Schema

reels_watch_events
ColumnTypeDescription
event_idPKINTUnique event identifier
user_idINTMeta user identifier
surfaceVARCHAR(50)Instagram Reels entry surface
time_spent_secondsINTTime spent watching Reels in seconds; NULL indicates missing logging
event_dateDATEDate of the watch event
Tablesreels_watch_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results