Join fan-out explorer
Brightcart, an online grocery, joined orders to saved addresses to get revenue by city. Last month's report came out too high. Here you can watch it happen on five real customers from the lesson data, then fix it.
1. The two tables
A join pairs every order with every address that has the same customer_id. If each customer has one address, the key is one to one on the address side and each order appears once. Tick a box to give a customer a second saved address, and the address side becomes one to many.
Show both tables
2. The join
Predict the row count before you run it
Rows from a join = for each key, (left rows with that key) x (right rows with that key). For the LEFT JOIN, a left row with no match still gives one row.
The joined rows
Red rows are orders that appear more than once.
3. The same join on all of Brightcart
The explorer uses 5 customers. Press the button to run the selected join on all 360 orders and 154 addresses from the lesson.
4. Spot the mistake
Dev wants spend per customer for four customers and wrote this query. It runs with no error. One number in the result is wrong. Which one?