Streaks of cancelled orders: 'Москва', Feb–Apr 2025
Instructions
Take the deliveries of restaurants in the city 'Москва' created in the period February 1, 2025 to April 30, 2025 inclusive and order each restaurant's deliveries by created_at (ties by id). A streak is a maximal group of deliveries with status 'cancelled' that follow one another in this order for one restaurant (it may consist of a single delivery). For each restaurant with at least one such delivery, output restaurant_id, longest_streak (the length of the longest streak) and streak_start (created_at of the first delivery of that streak; if several streaks are the longest, the earliest one). Sort by restaurant_id.
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.