Average Session Duration from Load/Exit Pairs
Problem
**[Classic — session analytics]**
Each session has a `load` event and matching `exit` event. Calculate the
**average session duration in seconds** across all sessions.
Return `avg_duration_seconds` (rounded to 2 dp).
Tables
Example rows — the live problem includes the full dataset.
page_events
| event_id | session_id | event_type | event_time |
|---|
Expected output
Your answer should return 1 row with the columns avg_duration_seconds.
Starter code (SQL)
SELECT *
FROM page_events;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock