Everyone opens the SQL sandbox with the office supplies shop dataset.
Running the lesson
90 min- 10 min
Open the Tables panel. Which column of orders points at customers? Introduce primary and foreign keys.
- 15 min
Shop task 3, "Orders with names": the first join, written together.
- 15 min
LEFT JOIN: who has never ordered? Shop task 5 in pairs.
- 20 min
Shop tasks 4 and 6: joins with GROUP BY. Learners check their own answers.
- 20 min
The "Joining tables in SQL" exercise, with a class link if you want the results.
- 10 min
Wrap up: what happens without ON? Run it and count the rows.
A query to show at the end
SELECT customers.name, COUNT(orders.id) AS orders
FROM customers
LEFT JOIN orders ON orders.customer_id = customers.id
GROUP BY customers.name
ORDER BY orders DESC;Hannah Wolf shows 0: COUNT(orders.id) counts only rows where an order exists, while COUNT(*) would count her joined row as 1.
