SQL LEFT JOIN / GROUP BY / COUNT

Alphathree33

Platinum Member
Dec 1, 2000
2,419
0
0
SELECT Checkpoints.Name, COUNT(CheckpointVisits.CheckpointID) FROM Checkpoints LEFT JOIN CheckpointVisits ON Checkpoints.Name = CheckpointVisits.CheckpointID GROUP BY Checkpoints.Name

I was hoping this statement would give me all rows in Checkpoints even if they don't have matches in the JOIN with CheckpointVisits. (Which is why I chose a LEFT join, as that was my understanding of its meaning)

However it is still only returning rows from Checkpoints that have matches in CheckpointVisits.

Does this have something to do with my use of GROUP BY with an aggregate (COUNT)?
 

Alphathree33

Platinum Member
Dec 1, 2000
2,419
0
0
Nevermind. It helps if I use the database where I actually added the left join to the stored procedure.