Story Completion

ASKED IN INTERVIEW
4pts
Snap

Problem Statement

Snap engineers want to measure "Story Completion Rate". A user completes a story if the number of unique snaps they viewed for that story equals the story's total_snaps.

Write an SQL query to calculate the percentage of users who have completed at least one story they started.

Rules:

  • Completion Rate = (Users who completed at least one story / Users who viewed at least one snap) * 100.
  • Round the result to 2 decimal places.
  • Only consider users who appear in the Story_Views table.
  • Output columns: completion_rate.
  • Result should be a single row.
Tests your understanding of
Aggregation, Ratios and Joins

Input Tables

Stories
story_id(INTEGER)total_snaps(INTEGER)
1013
1022
Story_Views
user_id(INTEGER)story_id(INTEGER)snap_index(INTEGER)
11011
11012
11013
21011
31021

Expected Output

completion_rate(DECIMAL)
33.33

Tags

MediumASKED IN INTERVIEWAggregationRatiosJoins
15-20 min
62%

Hints