Last delivery of 5+ km: Казань, strictly before July 1, 2025
Level: Middle100 XP
Instructions
For each courier from the city 'Казань' find their latest delivery among deliveries with distance_km of at least 5 whose delivered_at is not NULL and strictly before July 1, 2025. If a courier has several such deliveries with the same delivered_at, take the delivery with the larger id. Couriers without such deliveries are not in the result. Columns: courier_id, delivery_id (the delivery id), delivered_at, amount. Row order does not matter.
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
Exactly oneZero or oneZero or more
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
PostgreSQL
Select a table in the diagram or list to view its rows.