Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql include rows with 0 values

# 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;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sql #include #rows #values
ADD COMMENT
Topic
Name
6+8 =