The disappearing branch dashboard · COUNT(key) versus COUNT(*), and a condition in ON versus WHERE · level 2 of 6
Garden tools per branch, zero included
Level 2: Fill the blank · Exercise 1 of 1
The category condition is already in ON. One piece of the count is missing: what should be counted so that Cloquet, which owns no garden tools, shows 0?
Finish line:6 rows · columns branch_id, branch, garden_tools · in the order the question gives
Data: Twin Ports Tool Library.
Fill the blankOpening the database…
SELECT b.id AS branch_id, b.name AS branch, COUNT() AS garden_tools
FROM branches b
LEFT JOIN tools t ON t.branch_id = b.id AND t.category = 'Garden'
GROUP BY b.id, b.name
ORDER BY b.id;