FunctionRacerProblemsRace

Sessions

HardSQLSQLite

events logs what users did: minute is the time of an event, in minutes from the start of the log. A user's events fall into sessions: an event starts a new session when it comes more than 30 minutes after that user's previous event, and a user's first event always starts one. Return each user_id with sessions, the number of sessions that user had. Rows may come in any order.

Example 1

events
user_idminute
10
110
140
171
25
2300
returns
user_idsessions
12
22

Constraints

Race itor take your time

Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.

More SQL problems