Agent by month fact table of tickets created and resolved
The task
Support leaders want a monthly scorecard at the grain one row per agent per calendar month, for February to June 2025.
- An agent has a row for a month when
hired_onis before the first day of the next month. Agents are never removed. tickets_created: tickets assigned to the agent (tickets.agent_id) withcreated_atin that month.tickets_resolved: tickets assigned to the agent withresolved_atin that month. A ticket can be created in one month and resolved in a later one, and it counts in each month for its own event. Tickets with noresolved_atare never counted as resolved.- A month with no tickets of a kind shows 0.
Return agent_id, month (the first day of the month), tickets_created and tickets_resolved. Sort by agent_id, then month.
Expected output
agent_idmonthtickets_createdtickets_resolved- Sorted by agent_id ascending, then month ascending.
- 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
- Active accounts and seats per day from subscription datesmedium
- Daily stock levels with a date spine and carry forwardhard
- Monthly recurring revenue by plan with empty monthsmedium
- One row per savings account per month, with zero fillmedium
- Campaign by day fact table with cumulative spendhard
- Current gold customers by region from type 2 historyeasy
Loading the editor and PostgreSQL
Loading the editor and PostgreSQL