Sessionize Events (30 Minute Gap)
Hard
Window Functions
A new session starts when a user's gap since their previous event exceeds 30 minutes. Return user_id and the number of sessions per user, ordered by user_id.
Table schema
Events(user_id INT, event_time TIMESTAMP)Sample data
user_id | event_time
1 | 2026-05-01 10:00:00
1 | 2026-05-01 10:20:00
1 | 2026-05-01 11:30:00
2 | 2026-05-01 09:00:00
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.