Skip to content

Survey response rate and CSAT by team

MediumFull bankRatios and percentagesJoinsNULL handling15 min2 hidden datasets

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 satisfaction as a percentage of the tickets that were resolved (resolved_at is not NULL). Surveys are only sent for resolved tickets, so every survey answer belongs to a resolved ticket.
  • CSAT: the answers with a score of 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:

  • team
  • response_rate_pct (0 to 100), rounded to 1 decimal place
  • csat_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.

intUnique id.
textName.
textbilling, technical or general.
dateStart day.
tickets900 rows in the sample

One row per ticket. Key: ticket_id.

intUnique id.
intWho opened it.
intAssigned agent. NULL if never assigned.
textemail, chat or phone.
textlow, normal, high or urgent.
textbilling, bug, how_to or account.
timestampOpened (UTC).
timestampFirst reply from an agent. NULL if none yet.
timestampClosed as solved. NULL while open.
satisfaction366 rows in the sample

Survey answers, at most one per ticket. Key: ticket_id.

intThe ticket.
int1 (very unhappy) to 5 (very happy).
timestampWhen answered (UTC).

Related questions

Loading the editor and PostgreSQL