📜  sql 包含具有 0 值的行 - SQL 代码示例

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

代码示例1
# By default, INNER JOIN excludes person_id with no appointments (NULL value, COUNT(NULL)
# returns 0). Can learn/practice more at http://sqlzoo.net/wiki/Using_Null
SELECT person.person_id, COUNT(appointment.person_id) AS "number_of_appointments"
FROM person 
  LEFT JOIN appointment ON person.person_id = appointment.person_id
GROUP BY person.person_id;