Skip to content

Tickets by first response time band

MediumFull bankNULL handlingConditional aggregation12 min2 hidden datasets

The task

The support lead wants to see how long customers wait for a first reply. Put each ticket in one band, based on the time between created_at and first_response_at:

  • under_1h: less than 1 hour
  • under_24h: 1 hour or more, but less than 24 hours
  • 24h_plus: 24 hours or more
  • no_response: first_response_at is NULL (nobody has replied yet)

Return one row for each band that has at least one ticket:

  • band
  • tickets, the number of tickets in the band

Sort by band ascending.

Expected output

bandtickets
  • Sorted by band ascending.
  • 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