Loading...

Session Rank

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

Domain
SQL
Difficulty
medium

Problem

Analytics wants to see each user's sessions ranked by engagement. Within each user, number their sessions from longest to shortest by session_duration_sec. Skip rows where session_duration_sec is NULL. Return the user_id, duration, and position number.

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.