SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

User Session Reconstruction

Unsolved

Google Analytics defines a session by inactivity: a user's events belong to the same session until there is a gap of MORE than 30 minutes (1800 seconds) between two consecutive events of that user. A gap of exactly 30 minutes does not start a new session. Sessions can span midnight. Write an SQL query that returns, for every user, `user_id`, `session_count` (the number of sessions) and `largest_session_events` (the number of events in the user's biggest session). Order the results by `user_id` ascending.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Google🏢 Meta🏢 Amplitude

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM user_events
Full source dataset
14 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine