Re: array max min

From: Date: Mon, 05 Feb 2001 17:38:42 +0000
Subject: Re: array max min
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-38272@lists.php.net to get a copy of this message
<rui@websolut.net> 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/

« previous php.general (#38272) next »