Did you try
select count(*), sum(amount) from table1;
you also can use
 ... count(if(field=value,1,NULL)) ...

----- Original Message -----
From: jerome auza <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 14, 2001 2:49 AM
Subject: Help please: getting the total from the results of SUM


> Hi,
>
> Is it possible to get the total from the results of SUM in the same SQL
> statement?
>
> I want to have this output:
>
> Name    Amount     Percent
> Name1   15          25
> Name2   15          25
> Name3   30          50
>
> My database only have the first two columns and the Percent column is
> calculated as 100 * Amount/TOTAL where TOTAL is equal to the SUM of the
> Amounts.  Note that TOTAL would change if I have a different WHERE clause.
>
> Any help would be appreciated.
>
> jerome
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to