You're a product analyst at TuneWave, a music streaming service. The recommendations team wants to understand how continuously users listen to tracks: short gaps indicate uninterrupted playlist listening, while long gaps suggest a listener has returned to the app for a new session. You have a log of track starts called play_events, recording who pressed Play and when.
For each event, calculate how many minutes have passed since the same user's previous event. Exclude each user's first event from the result because there is no earlier event to compare it with.
Return these columns:
- user_id — listener ID;
- played_at — track start time (timestamp, as stored in the table);
- minutes_since_prev — the number of whole minutes since that user's previous event (all time intervals in the data are exact multiples of one minute).
Sort the result by user_id in ascending order, then by played_at in ascending order. Exclude users who have only one event. Timestamps do not repeat for the same user.
user_idplayed_atminutes_since_prevShowing the first 3 rows of the sample — the full sample comes with Premium
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in