List:General Discussion« Previous MessageNext Message »
From:Don Read Date:July 9 2001 7:50pm
Subject:RE: Dinstinct query
View as plain text  
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                                       dread@stripped
-- 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.
Thread
Dinstinct queryDaren Cotter9 Jul
  • RE: Dinstinct queryDon Read9 Jul
RE: Dinstinct queryDmitri Lubinski10 Jul
  • How can try to recover the data from mysqlRupak3 Aug
    • Re: How can try to recover the data from mysqlWerner Stuerenburg3 Aug