Interview practice question
Grouping events into sessions
Data Analyst · SQL for Analytics · Intermediate
You have raw click events with user ID and timestamp. How do you group them into sessions with a 30-minute inactivity rule?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- LAG timestamp per user.
- New session flag when gap > 30 min or first event.
- Running SUM of flags = session number.
- Session ID = user + number.
- Aggregate session metrics.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.