Although it seems that you are not showing all the tables, I can only assume that there is a different actual registration table for each student
select a.Dept, count(*) as TotalStudents from students a group by a.Dept
If you want the total number of each department to be associated with each student (which does not make sense), you will probably have to do this as ...
select a.Dept, a.Name, b.TotalStudents from students a, ( select Dept, count(*) TotalStudents from students group by Dept ) b where a.Dept = b.Dept
My interpretation of your βNameβ column is the name of the student, not the name of the actual class instructor, so my sub-choice / connection. Otherwise, like the others, you just need to use COUNT (*) as the third column.
DRapp Apr 23 '10 at 11:36
source share