Tickets by first response time band
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 hourunder_24h: 1 hour or more, but less than 24 hours24h_plus: 24 hours or moreno_response:first_response_atis NULL (nobody has replied yet)
Return one row for each band that has at least one ticket:
bandtickets, 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.
| 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