Resolution speed buckets and satisfaction
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_atis NULLfast: resolved in less than 4 hours aftercreated_atsame day: resolved in 4 hours or more, but less than 24 hoursslow: 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.
| 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
Loading the editor and PostgreSQL
Loading the editor and PostgreSQL