Turn clickstream events into user sessions

Try this labAll DEA-C01 practice

Certification
DEA-C01
Format
SQL query
Difficulty
hard
Estimated time
20 min
Automated checks
9

SCENARIO

An app's analytics table contains page views from users who leave and return later. The current report merges each user's entire evening into one visit, making session duration and conversion analysis unreliable. A visit continues through gaps of 30 minutes or less; a longer gap starts a new session.

TASK

Repair session-audit.sql against web_events.

  • Return user_id, session_number, session_start, session_end, and event_count, with one row per session.
  • A gap exceeding 30 minutes starts a new session; exactly 30 minutes does not.
  • event_time is UTC epoch seconds, with event_id breaking ties.
  • Number sessions from 1 independently per user, retain every event, and order results by user_id then session_number.

Part of DEA-C01 preparation