First-response SLA by agent
The task
The support lead scores agents on first-response speed. Each ticket has a target that depends on its priority:
| priority | first reply due within |
|---|---|
| urgent | 1 hour |
| high | 4 hours |
| normal | 8 hours |
| low | 24 hours |
A ticket is graded like this, using the time from created_at to first_response_at:
met: there is a first response and it came within the target (exactly on the target counts as met)missed: there is a first response and it came after the targetpending: there is no first response yet (first_response_atis NULL); these are neither met nor missed
Only tickets assigned to an agent are graded. Return one row for every agent in agents, including agents with no tickets:
agent_idfull_namemet: number of met ticketsmissed: number of missed ticketspending: number of pending ticketsmet_pct:metas a percentage ofmet + missed, rounded to 1 decimal place, or NULL when the agent has no met or missed tickets
Sort by met_pct descending (NULLs last), then agent_id ascending.
Expected output
agent_idfull_namemetmissedpendingmet_pct- Sorted by met_pct descending, then agent_id 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