Same-Day Ticket Resolution Rate
Problem
Table: `Tickets`
```text
+-------------+---------+
| Column | Type |
+-------------+---------+
| ticket_id | int |
| user_id | int |
| opened_on | date |
| resolved_on | date |
+-------------+---------+
ticket_id is the primary key. Each row is one support ticket.
```
A ticket is **same-day** if it was resolved on the day it was opened
(`resolved_on` equals `opened_on`). Return the percentage of same-day tickets
across all tickets, rounded to 2 decimal places. Use the column heading
`same_day_pct`.
**Example**
```text
Tickets:
+-----------+---------+------------+-------------+
| ticket_id | user_id | opened_on | resolved_on |
+-----------+---------+------------+-------------+
| 1 | 10 | 2024-01-05 | 2024-01-05 |
| 2 | 11 | 2024-01-06 | 2024-01-08 |
| 3 | 12 | 2024-01-07 | 2024-01-07 |
+-----------+---------+------------+-------------+
Output:
+--------------+
| same_day_pct |
+--------------+
| 66.67 |
+--------------+
```
Two of the three tickets were resolved on the same day, so 2 / 3 = 66.67%.
Tables
Example rows — the live problem includes the full dataset.
| ticket_id | user_id | opened_on | resolved_on |
|---|---|---|---|
| 1 | 10 | 2024-01-05 | 2024-01-05 |
| 2 | 11 | 2024-01-06 | 2024-01-08 |
| 3 | 12 | 2024-01-07 | 2024-01-07 |
Expected output
Your answer should return 1 row with the columns same_day_pct.
Starter code (SQL)
SELECT *
FROM Tickets;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock