Uber Eats wants to identify each courier's longest delivery streak during 2025. A courier is active on a date if they completed at least one delivery that day. Return each courier's longest consecutive streak. If a courier has multiple streaks of equal length, return the streak with the earliest start date. Return `courier_id`, `streak_start`, `streak_end`, and `streak_days` in that order. Only deliveries with status `completed` between January 1, 2025 and December 31, 2025 should be considered. Multiple deliveries by the same courier on the same date count as one active day. ### Table Schema | Table | Column | Type | |---|---|---| | `deliveries` | `delivery_id` | integer | | `deliveries` | `courier_id` | integer | | `deliveries` | `delivered_at` | timestamp | | `deliveries` | `status` | varchar(20) | ### Example Input: `deliveries` | delivery_id | courier_id | delivered_at | status | |---:|---:|---|---| | 1 | 1 | 2025-01-01 10:00 | completed | | 2 | 1 | 2025-01-02 10:00 | completed | | 3 | 1 | 2025-01-04 10:00 | completed | | 4 | 2 | 2025-02-01 10:00 | completed | | 5 | 2 | 2025-02-02 10:00 | completed | | 6 | 2 | 2025-02-03 10:00 | failed | ### Example Output Explanation Courier 1 was active on January 1 and January 2, creating a two-day streak. January 4 is separated by a missing day, so it forms a one-day streak. Courier 2 has two completed consecutive days because the February 3 delivery failed.
DROP TABLE IF EXISTS deliveries; CREATE TABLE deliveries ( delivery_id INT, courier_id INT, delivered_at TIMESTAMP, status VARCHAR(20) ); INSERT INTO deliveries VALUES (1,1,'2025-01-01 10:00','completed'), (2,1,'2025-01-02 10:00','completed'), (3,1,'2025-01-04 10:00','completed'), (4,2,'2025-02-01 10:00','completed'), (5,2,'2025-02-02 10:00','completed'), (6,2,'2025-02-03 10:00','failed');