Average satisfaction score by channel
The task
The support lead wants the average satisfaction score by channel. Not every ticket gets a survey answer: satisfaction has at most one row per ticket, and many tickets have none. A ticket with no answer has no score, which is not the same as a score of 0, so it must not drag the average down.
For every channel that has at least one ticket, return:
channeltickets, the number of tickets in the channelanswers, the number of tickets with a survey answeravg_score, the averagescoreof the answers, rounded to 2 decimal places
A channel with no answers has no average, so return NULL for avg_score. Sort by channel ascending.
Expected output
channelticketsanswersavg_score- Sorted by channel 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