Video View Funnel

ASKED IN INTERVIEW
4pts
Tik Tok

Problem Statement

TikTok creators need to understand where their audience drops off. We track three specific events in the video player:

  1. started: The user clicked play.
  2. half_watched: The user reached 50% of the video duration.
  3. fully_watched: The user reached 100% of the video.

Write an SQL query to calculate the overall conversion rates for the entire platform.

Rules:

  • Calculate two metrics:
    • half_rate: (Users who reached half_watched) / (Users who started)
    • full_rate: (Users who reached fully_watched) / (Users who started)
  • Use unique user counts for each stage.
  • Results should be rounded to 2 decimal places.
  • Output columns: half_rate, full_rate.
  • If no videos were started, return 0.00 for both rates.
Tests your understanding of
Funnel Analysis, Aggregation and CASE WHEN

Input Tables

Events
event_id(INTEGER)user_id(INTEGER)video_id(INTEGER)event_type(VARCHAR)timestamp(TIMESTAMP)
1110started2026-02-10 10:00:00
2110half_watched2026-02-10 10:00:15
3110fully_watched2026-02-10 10:00:30
4210started2026-02-10 10:01:00
5210half_watched2026-02-10 10:01:15
6311started2026-02-10 10:02:00
Videos
video_id(INTEGER)creator_id(INTEGER)duration(INTEGER)
105030
115160
125215
135345
145420
1555120
Users
user_id(INTEGER)region(VARCHAR)
1US
2UK
3IN
4BR
5JP
6DE

Expected Output

half_rate(DECIMAL)full_rate(DECIMAL)
0.670.33

Tags

MediumASKED IN INTERVIEWFunnel AnalysisAggregationCASE WHEN
15-20 min
62%

Hints