On 05-Feb-2001 Steve Werby wrote:
> <[EMAIL PROTECTED]> wrote:
>> i thought about that, but i gave up on my first attempt on doing so,
> because
>> mysql complained about my query, it seems that it doesn't allow to use the
>> max() function with a sum() function, an example of the query is:
>>
>> SELECT month,
>>        daynr,
>>        hour,
>>        sum(numberofusers),
>>        sum(numberofmails),
>>        sum(numberofdownloads)
>> FROM table
>> GOURP BY month, daynr, hour
>> WHERE where_clause;
>>
>> and mysql complaints when i do another column with max(sum(numberofusers))
>:\
> 
> You just need to add a column max(numberofusers).  You've already grouped by
> month, day and hour so:
> 
> sum(numberofusers) => total # of users for that month/day/hour/
> max(numberofusers) => max # of users for any record for that month/day/hour
> 
> If you're really trying to get the total # of users for the single
> month/day/hour with the most users then you need a second query.  If you can
> put into sentences exactly what you're trying to do, we can probably help
> you a little better.
> 
>> i think i'm doomed with the big loop thing :\
> 
> Nah, I think you can avoid it.  MySQL is your friend.  <grin>
> 
> --
> Steve Werby
> COO
> 24-7 Computer Services, LLC
> Tel: 804.817.2470
> http://www.247computing.com/
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


ok, this is the real query:

select sum(numberofusers),
       sum(numberofmails),
       sum(numberofdownloads),
       month(data) as month,
       hour 
from account, site 
where site.pid=account.id and site.siteid=10
and hour!=''
group by month,hour order by month,hour

while($db->next_record())
 row[$db->Record[3]][$db->Record[4]]=$db->Record;
}

then display the table

|       |month1 |month2 |
|hour1  |value  |value  |
|hour2  |value  |value  |

and to distinguish the maximum value and minimum value with somekind of color
or bold or something.

this is the whole job, i can't seem to find another way beside the loop
thing...
thanks a lot for the help guys. 

               Rui Barreiros
          Software Developer

WEBSOLUT - Soluções Internet
Emailto: [EMAIL PROTECTED] 
Personal Info: http://websolut.net/people/rui.html

As informações contidas neste email são confidenciais
e destinam-se apenas à(s) pessoa(s) a quem foi enviado:
http://websolut.net/confidencialidade-responsabilidade.html


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to