AnalystPath

Session Length Bucket Histogram

SQLMediumMid level~15 min

Problem

**[Classic — session analytics]**

Bucket sessions by `duration_seconds` into four ranges:
- `<1min`: < 60 seconds
- `1-5min`: 60-299 seconds
- `5-15min`: 300-899 seconds
- `15min+`: >= 900 seconds

Return `bucket` and `session_count`, ordered from shortest to longest bucket.

Tables

Example rows — the live problem includes the full dataset.

sessions
session_iduser_idduration_seconds

Expected output

Your answer should return 4 rows with the columns bucket, session_count.

Starter code (SQL)

SELECT *
FROM sessions;

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

Related SQL questions