I would like to track how many surveys have been done by different departments at work. This is fairly easy to do by using "Group by" and counting the number of matches.
SELECT Departments.DepartmentName, count(*) as [survey count]
FROM Departments INNER JOIN
Surveys ON Departments.DepartmentID = Surveys.DepartmentID
GROUP BY Departments.DepartmentName
but this only shows departments that have completed surveys. How would I have the departments that have not completed surveys represented on the results list as a zero count?
Update:
SELECT Departments.DepartmentName AS Department,
COUNT( Surveys.DepartmentID) AS [survey count]
, Departments.DepartmentID
FROM Surveys FULL OUTER JOIN
Departments ON Surveys.DepartmentID = Departments.DepartmentID
GROUP BY Departments.DepartmentName, Departments.DepartmentID