Task
Nimbus Logistics wants a simple view of operational workload over time. Write a PostgreSQL query to analyze monthly support ticket trends from a single table.
Requirements
- Group tickets by month using the
created_at date.
- Return the month in
YYYY-MM format and the total number of tickets created in that month.
- Exclude rows where
created_at is NULL.
- Sort the results by month ascending.
Table Definition
support_tickets
| column | type | description |
|---|
| ticket_id | INT | Primary key for each ticket |
| team_name | VARCHAR(50) | Team handling the ticket |
| priority | VARCHAR(20) | Ticket priority level |
| status | VARCHAR(20) | Current ticket status |
| created_at | DATE | Date the ticket was created |
| | |
Sample Data
| ticket_id | team_name | priority | status | created_at |
|---|
| 1 | Fulfillment | High | Open | 2024-03-02 |
| 2 | Warehouse | Medium | Closed | 2024-01-15 |
| 3 | Fulfillment | Low | Open | 2024-02-10 |
| 4 | Returns | High | Closed | 2024-01-28 |
| 5 | Warehouse | Medium | Open | 2024-03-18 |
| 6 | Fulfillment | Low | Closed | 2024-02-25 |
| 7 | Returns | Medium | Open | 2024-01-03 |
| 8 | Warehouse | High | Open | NULL |
| 9 | Fulfillment | Medium | Closed | 2024-03-01 |
| 10 | Returns | Low | Open | 2024-02-14 |
| | | | |
Expected Output
| ticket_month | ticket_count |
|---|
| 2024-01 | 3 |
| 2024-02 | 3 |
| 2024-03 | 3 |