Courier idle periods of 7+ days: 'Екатеринбург', bike
Instructions
A courier's working day is a calendar day on which at least one of the courier's deliveries with status 'delivered' was created (by created_at). An idle period is an unbroken run of days without working days between two consecutive working days of a courier (days before the first and after the last working day do not count). For couriers from the city 'Екатеринбург' with vehicle 'bike', find all idle periods of at least 7 days over the whole time. Output courier_id, idle_from and idle_to (the first and last day of the idle period) and idle_days (the number of days in it; between working days March 1 and March 4 the idle period lasts 2 days). Sort by idle_days descending, then courier_id, then idle_from ascending.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Table relationships
- N:1Many-to-one
deliveries.→restaurant_id restaurants.id - N:1Many-to-one
deliveries.→customer_id customers.id - N:1Many-to-one
deliveries.→courier_id couriers.id
Table data
Select a table in the diagram or list to view its rows.