Re: code help!

From: Date: Tue, 05 Sep 2000 15:36:26 +0000
Subject: Re: code help!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-15323@lists.php.net to get a copy of this message
select sum(sales) from table group by zipcode Michael Roark wrote: > On Tue, 5 Sep 2000, Cobra Commander wrote: > > > I assume this is a DB. > > > > Select * from TABLENAME where ZIPCODE = 'ZIPCODE' > > Then you can run a loop and do the sum OR (my MYSQL is limited): > > > > there maybe something like: > > > > Select sum(sales) as SALESSUM from TABLENAME where ZIPCODE = 'ZIPCODE' > > > > something to that effect will give you a single field with the sum oyu are > > looking for. > > ya the info is in a database. How do I know when all the zipcodes have > been sum'd? I mean if I loop through how does it know when its exausted > all the zipcodes? > > Additionally the above select (with the sum() function) works, however it > takes a second to execute on a zipcode which only had about 100 entries > (developement database server is small p166), > I've got some which have 900 to 1000 entries would it be more efficent to > do the summing in the php code rather than having the database do it? > > > > Here's what I need to do: > > > > > > I've got a demographic, one field is a zip code field and there can be > > > many entries for the same zipcode. I want to select all the info for like > > > zipcodes and then sum the totals (say sales field) for each zip code and > > > then list the top 5 zip codes. > > > > > > If someone could help me out with this one it would be much appriciated. > > > > > > Thanks, > > > > > > Michael > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#15323) next »