Table: orders
+---------------+----------+ | Column Name | Type | +---------------+----------+ | order_id | int | | order_time | datetime | | delivery_time | datetime | +---------------+----------+
order_idis the primary key. Each row records when an order was placed and when it was delivered.
Compute the percentage of orders that are late, where late means the delivery took more than 15 minutes from order placement. Return late_pct rounded to 2 decimal places on a 0 to 100 scale.
The result format is shown below.
Example
Input:
orders table: +----------+---------------------+---------------------+ | order_id | order_time | delivery_time | +----------+---------------------+---------------------+ | 1 | 2024-01-01 10:00:00 | 2024-01-01 10:10:00 | | 2 | 2024-01-01 10:00:00 | 2024-01-01 10:20:00 | | 3 | 2024-01-01 10:00:00 | 2024-01-01 10:15:00 | | 4 | 2024-01-01 10:00:00 | 2024-01-01 10:30:00 | +----------+---------------------+---------------------+Output:
+----------+ | late_pct | +----------+ | 50.0 | +----------+Explanation:
Orders 2 (20 min) and 4 (30 min) exceed 15 minutes. Orders 1 (10 min) and 3 (exactly 15 min) are on time. 2 of 4 = 50.0%.
Accepted
25/84
Acceptance Rate29.8%
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
-
Output
-
Expected
-