[thelist] Better way to do this (SQL)?

Michael Pemberton evolt at mpember.net.au
Tue May 18 05:53:03 CDT 2004


Burhan Khalid wrote:
> Basically, I would like to show:
> 
> total headcounts and percentages for 'male' and 'female' respondents 
> (database column 'sex')"
> 

this is rushed and hasn't been tested, but here goes....

SELECT sex, count( `sex` ) FROM `table` GROUP BY `sex`;

should return:

male  	xx
female 	yy

By adding the two rows, you can get the total rows.
-- 
Michael Pemberton
evolt at mpember.net.au



More information about the thelist mailing list