[thelist] MySQL COUNT() question

Aron Lurie alurie at hebrewcollege.edu
Mon Nov 14 19:14:02 CST 2005

Hey, I have a MySQL problem that is posing a severe challenge to me regarding COUNT().
Right now I have the following code:
select CONCAT(fpe.fname,' ',fpe.lname) fullname, 
 COUNT(*) student_num 
from f05people fpe,
 f05classes fce, 
 people pe,
 f05studentsched fss 
where pe.hcid=fpe.hcid 
 and pe.alias=fce.Faculty 
 and fpe.Faculty='Yes' 
 and fce.Branch='HC-Tuesday' 
 and fce.period='1' 
 and fss.period='1' 
 and fss.branch='HC-Tuesday' 
 and fss.teacher = pe.alias 
 group by fss.branch, fss.teacher,fss.period order by fce.Faculty ASC;

This works fine so far returning all the values I want, however...
The problem is that I want another COUNT(*) column that is grouped by a different set of fields in a different table. Is there a way to have two group by statements? How would I do this?
Any help is greatly appreciated.
Aron Lurie 
alurie [at] hebrewcollege [dot] edu

More information about the thelist mailing list