Сколько строк дают разные соединения
Questions like this come up in interviews at Amazon
Level: JuniorTopic: JOIN50 XP
Instructions
Пусть m — доставки, созданные (created_at) не раньше 1 марта 2025 и строго раньше 1 апреля 2025. У части из них курьер не назначен (courier_id равен NULL), а у курьеров бывает много доставок или ни одной. Соедините couriers c и m по условию m.courier_id = c.id и посчитайте, сколько строк даёт каждое соединение: inner_rows — JOIN, left_rows — couriers LEFT JOIN m, right_rows — couriers RIGHT JOIN m, full_rows — FULL JOIN. Выведите одну строку с этими четырьмя числами.
not translated yetHints
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.