Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Video Drop-Off SQL Query
00:00
5 left

Video Drop-Off SQL Query

MediumSQL · PostgreSQL

Problem

Write a query to identify users who dropped off after the first 5 minutes of a video on Hotstar.

Treat a drop-off as a viewing session where the user watched at least 300 seconds but did not watch the video to completion. Return qualifying sessions only.

Output

  1. One row per qualifying viewing session
  2. Columns: session_id, user_id, user_name, video_id, video_title, and watched_seconds
  3. Order by watched_seconds descending, then user_id ascending and video_id ascending

Schema

users
ColumnTypeDescription
user_idPKINTUnique Hotstar user identifier
user_nameVARCHAR(100)Display name of the user
emailVARCHAR(255)User email address
videos
ColumnTypeDescription
video_idPKVARCHAR(20)Unique Hotstar video identifier
video_titleVARCHAR(200)Video title
duration_secondsINTFull video duration in seconds
viewing_sessions
ColumnTypeDescription
session_idPKINTUnique viewing session identifier
user_idINTUser who watched the video
video_idVARCHAR(20)Video watched during the session
watched_secondsINTMaximum playback position reached in seconds
Tablesviewing_sessionsusersvideos
Interviewer

Your question is Video Drop-Off SQL Query. Start with the requirements and the three tables in the Question tab.

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.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.