SELECT a.ClassName, b.TeacherName, COUNT(c.Class_ID)
from dbo.Class a
inner join dbo.Teacher b on a.Teacher_ID = b.Teacher_ID
left outer join dbo.ClassRegistration c on a.Class_ID = c.Class_ID
group by a.ClassName, b.TeacherName
I currently have the above SQL script. It works fine, the idea is to display the ClassName, TeacherName and count of how many times this class appears in the ClassRegistration table. Now the next part is where I’m a bit stuck. On the ClassRegistration table is also a column called ‘HasPaid’. I need to add a 2nd Count column that will display how many “ClassRegistration’s” have been paid for.
Try this:
if HasPaid is of type
BIT, you may simplify second count in such a way: