Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

User Watch Percentage by Show

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

Your question is User Watch Percentage by Show. Start with the requirements and the two tables 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

Paramount+ wants to measure the reach of a specific show across its registered users. Write a PostgreSQL query that calculates the percentage of all users who watched Star Trek: Strange New Worlds at least once.

Requirements

  1. Count each qualifying user only once, even if they watched the show multiple times.
  2. Use all rows in users as the denominator, including users with no views.
  3. Return one row containing the number of unique viewers, total users, and viewer percentage rounded to two decimal places.
  4. Treat only exact matches to the specified show title as qualifying views.

Schema

users
ColumnTypeDescription
user_idPKINTUnique Paramount+ user identifier
emailVARCHAR(255)User email address
subscription_tierVARCHAR(20)Current subscription plan
views
ColumnTypeDescription
view_idPKINTUnique viewing event identifier
user_idINTUser associated with the viewing event
show_titleVARCHAR(150)Title of the show watched
viewed_atTIMESTAMPTimestamp when the view occurred
Tablesusersviews
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results