Three slowest first responses in each channel
The task
The support lead is reviewing the slowest first replies. For each ticket that has a first_response_at, the response time is the number of minutes from created_at to first_response_at. Tickets that never got a first response have no response time and are left out.
Within each channel, rank the answered tickets from the slowest to the fastest and return the 3 slowest. If two tickets have exactly the same response time, the one with the lower ticket_id comes first. A channel with fewer than three answered tickets returns what it has.
Return channel, ticket_id, response_minutes (the response time rounded to 1 decimal place) and slow_position (1, 2 or 3). Rank on the exact time and round only for display. Sort by channel ascending, then slow_position ascending.
Expected output
channelticket_idresponse_minutesslow_position- Sorted by channel ascending, then slow_position ascending.
- Numbers rounded to 1 decimal place.
- Checked on the sample and on 2 hidden datasets. How grading works
Tables Customer support desk · click a name to insert it
agents14 rows in the sample
Support agents. Key: agent_id.
| int | Unique id. | |
| text | Name. | |
| text | billing, technical or general. | |
| date | Start day. |
tickets900 rows in the sample
One row per ticket. Key: ticket_id.
| int | Unique id. | |
| int | Who opened it. | |
| int | Assigned agent. NULL if never assigned. | |
| text | email, chat or phone. | |
| text | low, normal, high or urgent. | |
| text | billing, bug, how_to or account. | |
| timestamp | Opened (UTC). | |
| timestamp | First reply from an agent. NULL if none yet. | |
| timestamp | Closed as solved. NULL while open. |
satisfaction366 rows in the sample
Survey answers, at most one per ticket. Key: ticket_id.
| int | The ticket. | |
| int | 1 (very unhappy) to 5 (very happy). | |
| timestamp | When answered (UTC). |
Related questions
- Average first purchase value by campaign, organic includedmedium
- Driver rating leaderboard, unrated drivers lastmedium
- Repeat contact within 14 days of a first tickethard
- Top two agents per team by satisfaction, with tie-breakersmedium
- Best seller on each sales channel in the first quartermedium
- Each customer's largest single expense, with tie-breakersmedium
Loading the editor and PostgreSQL
Loading the editor and PostgreSQL