AnalystPath

Longest Support Sessions per Channel

SQLMediumMid level~15 min

Problem

A help desk handles sessions over two channels: `chat` and `voice`. The table `Agents` lists each agent's `agent_id` and `given_name`; the table `Sessions` lists each session's `agent_id`, the `channel` it ran on, and its `seconds_long` (the session length in seconds). For each channel, find the three longest sessions. Return the agent's `given_name`, the `channel`, and the duration as `clock` formatted HH:MM:SS. If two sessions tie on length they are both kept (ranking by length, ties sharing a rank). Order the result by `channel`, then by duration descending, then by `given_name` descending for ties.

Tables

Example rows — the live problem includes the full dataset.

Agents
agent_idgiven_namesurname
1LiamCarter
2NoraPatel
3OwenReyes
Sessions
agent_idchannelseconds_long
1chat120
1voice180
2chat300

Expected output

Your answer should return 6 rows with the columns given_name, channel, clock.

Starter code (SQL)

SELECT *
FROM Agents;

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