Skip to content

Resolution speed buckets and satisfaction

MediumFull bankGroup and aggregateDates and timeJoins14 min2 hidden datasets

The task

The support lead wants to know whether slow resolutions make customers unhappy. Put every ticket in tickets into one speed bucket:

  • open: resolved_at is NULL
  • fast: resolved in less than 4 hours after created_at
  • same day: resolved in 4 hours or more, but less than 24 hours
  • slow: resolved in 24 hours or more

A ticket resolved after exactly 4 hours is same day, and one resolved after exactly 24 hours is slow.

Return speed (the exact labels above), tickets (how many tickets are in the bucket), surveys (how many of them have a row in satisfaction) and avg_score (the average score of those surveys, rounded to 2 decimal places, or NULL when the bucket has no survey).

A bucket with no tickets is left out. Sort by tickets descending, then speed ascending.

Expected output

speedticketssurveysavg_score
  • Sorted by tickets descending, then speed ascending.
  • Numbers rounded to 2 decimal places.
  • 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