I'm not entirely sure I know what you're asking when you say that you want
to "group a field together with COUNT()".

If you mean that you want to be able to count() and sum() or avg() the
groups, then the answer is yes. For example, let's say that you have an
Employee table with one row per employee. Each row also contains a
department number, indicating the department for which the employee works.
In that case:

    select deptno, count(*), sum(salary), avg(bonus)
    from Employee
    group by deptno

will return one row for each department number that exists in the table.
Each result set row will contain a department number, the number of
employees who belong to that department, the total salary paid out to all
employees in that department, and the average bonus paid out to all
employees in that department.

If this isn't what you wanted, please clarify the question and someone else
will probably try to answer the clarified question.

Rhino

----- Original Message ----- 
From: "Eric Jensen" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Friday, April 29, 2005 5:38 PM
Subject: Sum of a Count


> Is there a way to group a field together with COUNT() and run a SUM() or
> AVG() on that?  I've looked all over and I can't see a way to combine
> them, but maybe there is a trickier way?
>
> Eric Jensen
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.11.0 - Release Date: 29/04/2005
>
>



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.0 - Release Date: 29/04/2005


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to