On 09-Jul-01 Daren Cotter wrote:
> I have two fields, sex, and age, which are both ENUM types. I'm building
> some statistical reports, using stuff like:
> 
> DISTINCT(sex) ... GROUP BY sex ...
> and
> DISTINCT(age) ... GROUP BY age ...
> 
> Now I want a report that shows me a breakdown by both categories, sex and
> age...so I can see not just how many m/f and 16-18 yr-olds, 19-24 yr-olds,
> etc, but how many of each sex in each age group. I've tried:
> 
> DISTINCT(sex, age) ... GROUP BY sex, age
> 
> But that doesn't work. Can someone help me out? Can I do this in one Query?
> 

distinct(term) ... group by (term)
  will always return one of each term, prolly not what you want.

Select sex,age,count(*) as cnt from da_table GROUP BY sex, age;

Regards,
-- 
Don Read                                       [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to