Instead of counting, why don't you try summing a couple of IIF/CASE statements? That is, using IIF, your query would be:
SELECT ClassId, COUNT(*) AS students,
SUM(IIF(StatusId = 1, 1, 0)) as Actives,
SUM(IIF(StatusId = 2, 1, 0)) as Inactives
FROM StudentsClasses
INNER JOIN Students ON StudentsClasses.StudentID = Students.StudentID
GROUP BY ClassId
lc
2010-06-18 18:02:30