Skip to content

Three slowest first responses in each channel

EasyFull bankRanking and top NNULL handling10 min2 hidden datasets

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.

intUnique id.
textName.
textbilling, technical or general.
dateStart day.
tickets900 rows in the sample

One row per ticket. Key: ticket_id.

intUnique id.
intWho opened it.
intAssigned agent. NULL if never assigned.
textemail, chat or phone.
textlow, normal, high or urgent.
textbilling, bug, how_to or account.
timestampOpened (UTC).
timestampFirst reply from an agent. NULL if none yet.
timestampClosed as solved. NULL while open.
satisfaction366 rows in the sample

Survey answers, at most one per ticket. Key: ticket_id.

intThe ticket.
int1 (very unhappy) to 5 (very happy).
timestampWhen answered (UTC).

Related questions

Loading the editor and PostgreSQL