Loading...

Session Page View Distance

A hard SQL interview practice problem on DataDriven. Write and execute real sql code with instant grading.

Domain
SQL
Difficulty
hard
Seniority
senior, staff

Problem

The UX research team is studying engagement depth within sessions. For each session, identify the first and last page view by view_id, then compute the distance as the last view's dur_ms minus the first view's dur_ms. Discard any session that contains only a single view. Return the average distance across all qualifying sessions. Sessions are linked to page views through user_id.

Practice This Problem

Solve this SQL problem with real code execution. DataDriven runs your SQL queries against a live PostgreSQL database and grades it instantly.