← Practice

Курьер с наибольшими чаевыми в городе до июля 2025

Questions like this come up in interviews at Uber

Level: MiddleTopic: CTE100 XP

Instructions

Учитывайте доставки, завершённые (delivered_at) строго раньше 1 июля 2025. Для каждого города курьера (couriers.city) найдите курьера с наибольшей суммой чаевых tip за этот период (пустые чаевые в сумму не входят; если у курьера все чаевые пустые, его сумма равна 0) (при равенстве выведите всех лидеров). Выведите city, name курьера и tips — сумму его чаевых. Порядок строк не важен.

not translated yet

Hints

Each next one is more detailed and costs more

Log in to open hints

Query

Result

Click Run to see the query result, or Check to submit your solution.

Dataset schema

deliveries.restaurant_id (0…N) ↔ restaurants.id (1…1)deliveries.customer_id (0…N) ↔ customers.id (1…1)deliveries.courier_id (0…N) ↔ couriers.id (0…1)couriersPKidintegercustomersPKidintegerdeliveriesPKidintegerFKrestaurant_idintegerFKcustomer_idintegerFKcourier_idintegerrestaurantsPKidinteger
Exactly oneZero or oneZero or more
Table relationships
  • N:1Many-to-onedeliveries.restaurant_id → restaurants.id
  • N:1Many-to-onedeliveries.customer_id → customers.id
  • N:1Many-to-onedeliveries.courier_id → couriers.id

Table data

PostgreSQL

Select a table in the diagram or list to view its rows.

Dataset schema