Gaps between plays

Gaps between plays

You are a product analyst at the music streaming service TuneWave. The recommendations team wants to know how densely listeners consume tracks: short pauses mean continuous playlist listening, long ones mean the person re-opened the app. You have the track-start log play_events: who pressed Play and when. For every event, compute how many minutes passed since the previous event of the same user. Skip the very first event of each user — there is nothing to compare it with. Return columns: - user_id — listener identifier; - played_at — track start time (timestamp, as stored); - minutes_since_prev — whole number of minutes since the user's previous event (all gaps in the data are exact minutes). Sort by user_id ascending, then played_at ascending. Users with a single event do not appear in the output. Timestamps never repeat within one user.

Exemplo de resposta esperada

É assim que se parece uma resposta correta: ela tem seu próprio número de linhas e não precisa coincidir com as tabelas do esquema. Sua resposta precisa retornar os mesmos nomes de colunas do exemplo: use AS para renomeá-las se for preciso.

user_idplayed_atminutes_since_prev
12026-05-01T09:03:003
12026-05-01T09:10:007
12026-05-01T10:00:0050
PostgreSQLv16
Entre para enviar

O resultado da sua consulta aparecerá aqui

Focus radio
Paused · SomaFM · Fluid