AnalystPath

Same-Day Repair Rate by Logged Date

SQLMediumMid level~15 min

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.

repair_ticket
ticket_iddevice_idlogged_datefixed_date
1112024-03-012024-03-02
2122024-03-012024-03-01
3112024-03-012024-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

Related SQL questions