Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
SQL for User Behavior
00:00
5 left

SQL for User Behavior

MediumSQL · PostgreSQL

Problem

How would you write a SQL query to answer a business question about user behavior at Paramount? Using the supplied users, viewing_sessions, and titles tables, return users with at least two completed viewing sessions during January 2026.

Output

  1. One row per qualifying user with user_id, display_name, subscription_plan, completed_sessions, total_watch_minutes, distinct_titles, and engagement_level
  2. Include only users with at least two completed sessions in January 2026
  3. Sort by total_watch_minutes descending, then user_id ascending

Schema

users
ColumnTypeDescription
user_idPKINTUnique Paramount+ user identifier
display_nameVARCHAR(100)User display name
subscription_planVARCHAR(30)Current Paramount+ subscription plan
viewing_sessions
ColumnTypeDescription
session_idPKINTUnique viewing session identifier
user_idINTUser associated with the session
title_idINTWatched title identifier
session_startedTIMESTAMPSession start timestamp
session_endedTIMESTAMPSession end timestamp, null for incomplete sessions
watch_minutesINTMinutes watched during the session
titles
ColumnTypeDescription
title_idPKINTUnique Paramount+ title identifier
title_nameVARCHAR(150)Title name
genreVARCHAR(50)Primary title genre
Tablesusersviewing_sessionstitles
Interviewer

Your question is SQL for User Behavior. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.