Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Buffering Users SQL Query

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

Your question is Buffering Users SQL Query. 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

Twitch Operations wants to identify viewers who experienced frequent playback interruptions while still accumulating substantial watch time. Write a PostgreSQL query to find the top ten qualifying Twitch users.

Requirements

  1. Join Twitch users to their event records.
  2. Calculate each user's total watch time in seconds from watch events.
  3. Count each user's buffering events and retain only users with more than three.
  4. Return up to ten users ordered by total watch time descending, using user_id as a deterministic tie-breaker.

Schema

twitch_users
ColumnTypeDescription
user_idPKINTUnique Twitch user identifier
usernameVARCHAR(50)Twitch username
twitch_user_events
ColumnTypeDescription
event_idPKINTUnique event identifier
user_idINTUser associated with the event
event_typeVARCHAR(20)Event category
duration_secondsINTWatch duration in seconds, when applicable
Tablestwitch_userstwitch_user_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results