📅  最后修改于: 2022-03-11 15:05:26.711000             🧑  作者: Mango
# To count the number of teachers in each department, including
# rows where COUNT(t.name) == 0
SELECT d.name,COUNT(t.name) FROM teacher t
RIGHT JOIN dept d ON (t.dept=d.id) GROUP BY d.name;