Look into cross-tab queries (I think that's what they are called). There
is a good article on Devshed.com about it. You can do a query like this

SELECT SUM(IF(Gender='M'),1,0)) AS Male, SUM(IF(Gender='F',1,0)) AS
Female FROM table

That'll give you two columns, one named Male, one named Female, in the
result set. The result set will have one row, containing the number of
males in the database in the Male column, the number of females in the
database in the second.

You could probably do the majority of your "statistic" queries this way.

---John Holmes...

> -----Original Message-----
> From: Rodrigo Peres [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, June 02, 2002 2:02 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] php to generate statiscs
> 
> Hi list,
> 
> Sorry if this is a off-topic, but I really don't know where to begin.
I
> have a mysql database with about 20.000 records, now I need to build a
> statistics panel to show for example how many of this record are male,
> female, lives in determinated city, school graduation etc, everything
> grouped by sex and alone too, present the respectives percentages
etc...
> How do I begin??? Can someone help??
> 
> thank's in advance
> 
> Rodrigo Peres
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to