The new COUNT would be of the same type (branch,teacher,period) as fss, but it would be from a different table called f05lr_comments Aron Lurie alurie [at] hebrewcollege [dot] edu ________________________________ From: thelist-bounces at lists.evolt.org on behalf of Matt Warden Sent: Mon 11/14/2005 8:52 PM To: thelist at lists.evolt.org Subject: Re: [thelist] MySQL COUNT() question -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Aron Lurie wrote: > 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, > pe.alias, > fce.Course, > 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? > Not like that, no. What count do you want? If it is truly separate from this query, you need another query. However, if it is a field in this query, we can probably come up with a solution for you. - -- Matt Warden Miami University Oxford, OH, USA http://mattwarden.com This email proudly and graciously contributes to entropy. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD4DBQFDeT9urI3LObhzHRMRAr7kAJdx0vrKXxWSR9KR4Qd1anN9+QbmAJ9t1fWh i4d6Eq+EgixfkbIhiXWYcA== =DADH -----END PGP SIGNATURE----- -- * * Please support the community that supports you. * * http://evolt.org/help_support_evolt/ For unsubscribe and other options, including the Tip Harvester and archives of thelist go to: http://lists.evolt.org Workers of the Web, evolt !