Survey response rate and CSAT by team
The task
The support lead tracks two numbers for every team, and they have different denominators.
- Survey response rate: the tickets with a row in
satisfactionas a percentage of the tickets that were resolved (resolved_atis not NULL). Surveys are only sent for resolved tickets, so every survey answer belongs to a resolved ticket. - CSAT: the answers with a
scoreof 4 or 5 as a percentage of all answers.
A ticket belongs to the team of its assigned agent. Tickets with no agent belong to no team and are ignored.
Return one row for every team in agents:
teamresponse_rate_pct(0 to 100), rounded to 1 decimal placecsat_pct(0 to 100), rounded to 1 decimal place
When a rate has nothing to divide by (no resolved tickets, or no answers), return NULL for it. Sort by team ascending.
Expected output
teamresponse_rate_pctcsat_pct- Sorted by team 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