JOINs with GROUP BY
Let’s say we want to
display the names of all unique courses and the
total number of students enrolled in each course.
In this case, we can use
GROUP BY clause for the number of students, over the
JOIN of tables
Take a close look at the results, not all courses are included in the records. Course
C, that does not have any students enrolled in it, doesn’t show up. We need to use a
LEFT OUTER JOIN/
LEFT JOIN in this case, keeping
courses at the left, so that all the records from courses show up, irrespective of matching records from the table at the right.