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
First Movie Stream per User
00:00
5 left

First Movie Stream per User

MediumSQL · PostgreSQL

Problem

Using the same STREAMS/TITLES tables, find the name and title id of the first movie streamed by each user each day.

Asked in the phone screen stage.

Output

  1. Return one row per user and calendar day with columns user_id, stream_date, name, and title_id.
  2. Include only the earliest valid movie stream for each user and day. Ignore streams without a timestamp or matching title.
  3. Order by user_id, then stream_date, both ascending. Break timestamp ties with the lowest stream_id.

Schema

streams
ColumnTypeDescription
stream_idPKINTUnique stream event identifier
user_idINTIdentifier of the user who streamed the movie
stream_timestampTIMESTAMPTZTimestamp when the movie stream began
title_idINTMovie identifier referenced in titles
titles
ColumnTypeDescription
title_idPKINTUnique movie identifier
nameVARCHAR(150)Movie title name
Tablesstreamstitles
Interviewer

Your question is First Movie Stream per User. Start with the requirements and the two 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.