Skip to content

Tickets per response band from a band lookup table

MediumFull bankJoinsDates and timeConditional aggregation15 min3 hidden datasets

The task

The support team reports how fast it answers. The response time of a ticket is the time from created_at to first_response_at, in minutes (fractions allowed). Each ticket falls into one band; the lower limit is included and the upper limit is not:

band_rank band from (minutes) up to (minutes)
1 'under_15m' 0 15
2 '15m_to_1h' 15 60
3 '1h_to_24h' 60 1440
4 'over_24h' 1440 no limit
5 'no_response' tickets with first_response_at NULL

Return one row for every band, including bands with no tickets:

  • band_rank
  • band
  • tickets: number of tickets in the band

Sort by band_rank.

Expected output

band_rankbandtickets
  • Sorted by band_rank ascending.
  • Checked on the sample and on 3 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