Amazon | Data Scientist | Phone Screen | SQL

Hi folks, just wanna share a few sql questions I had on a recent Amazon Data Scientist phone interview

there are 2 tables: STREAMS and TITLES

STREAMS table
USER_ID
TITLE_ID
STREAM_TIMESTART
STREAM_MINUTES
Key for this table is (USER_ID,TITLE_ID,STREAM_TIMESTART)

TITLES table

TITLE_ID
GENRE
NAME
LAUNCH_DATE

Key for this table is TITLE_ID
  1. Find the number of times of each movie (title) was streamed and the total minutes streamed and the movie's genre in the month of December 2018.
    My solution: Straightforward join and group by
  2. Find the name and title id of the first movie streamed by each user each day.
    My solution: Window function parition by USER_ID and date(STREAM_TIMESTART) and order by STREAM_TIMESTART here, taking row_number()==1.
  3. Find the total minutes streamed for each movie within the first 28 days since the movie's launch date.
    My solution: I did a join with a filter LAUNCH_DATE + INTERVAL 28 DAYS >= date(STREAM_TIMESTART) here but the interviewer did not seemed to like/understand this approach and kept asking me for an alternative approach. I guess he found it unintuitive? Anyone else got another idea please?
Comments (8)