First response times by priority
The task
The support lead wants a response-time summary for each ticket priority, using every row in tickets.
A ticket's response time is the number of minutes from created_at to first_response_at. It only exists when first_response_at is not NULL.
Return:
prioritytickets: the number of ticketsunanswered: how many tickets have no first response yetavg_response_minutes: the average response time over answered tickets, rounded to 1 decimal place, or NULL when no ticket of that priority has been answeredmax_response_minutes: the longest response time over answered tickets, rounded to 1 decimal place, or NULL when none
Sort by priority ascending.
Expected output
priorityticketsunansweredavg_response_minutesmax_response_minutes- Sorted by priority ascending.
- Numbers rounded to 1 decimal place.
- 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