Same-Day Repair Rate by Logged Date
Problem
Table: `repair_ticket`
| Column Name | Type |
|---|---|
| ticket_id | int |
| device_id | int |
| logged_date | date |
| fixed_date | date |
`ticket_id` is the primary key. A ticket is a *same-day repair* when its `fixed_date` equals its `logged_date`.
For each distinct `logged_date`, compute the percentage of tickets logged that day that were same-day repairs. Round the percentage to 2 decimal places and alias it `same_day_rate`. Output `logged_date` and `same_day_rate`, ordered by `logged_date`.
Tables
Example rows — the live problem includes the full dataset.
| ticket_id | device_id | logged_date | fixed_date |
|---|---|---|---|
| 1 | 11 | 2024-03-01 | 2024-03-02 |
| 2 | 12 | 2024-03-01 | 2024-03-01 |
| 3 | 11 | 2024-03-01 | 2024-03-01 |
Expected output
Your answer should return 2 rows with the columns logged_date, same_day_rate.
Starter code (SQL)
SELECT *
FROM repair_ticket;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