Interview Questions/SQL/Support Ticket Resolution Stats

Support Ticket Resolution Stats

Preview mode. Log in to edit, run, submit, and save progress.

Medium

Support Ticket Resolution Stats

You are given a table of support tickets. Each ticket has a priority level ('high', 'medium', or 'low'), a status ('resolved' or 'open'), a creation date, and an optional resolved date. Write a SQL query to find for each month and priority: the total number of tickets, the number of resolved tickets, the number of open tickets, and the resolution rate as a percentage (resolved / total × 100, rounded to 2 decimal places). Return the result ordered by month and priority. Table: Tickets

Column NameTypeDescription
idINTPrimary key
priorityVARCHAR'high', 'medium', or 'low'
statusVARCHAR'resolved' or 'open'
created_dateDATEDate the ticket was opened
resolved_dateDATEDate resolved (NULL if still open)

Examples

Example 1

Group by month and priority. Use CASE WHEN to count resolved and open separately. Resolution rate = resolved_count / total_tickets * 100.

Approach hint

Start with a simple approach, explain the trade-off, then move toward a cleaner or more scalable solution.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

query.sql