📜  sql 计数匹配分组依据 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:26.711000             🧑  作者: Mango

代码示例1
# 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;