Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GROUP BY and count on different fields same table 2

Status
Not open for further replies.

supmrio

Technical User
Jan 7, 2003
7
US
Hi, I am new at ACCESS. WHen I do a query using let's say,
the field called GENDER, and I have two rows, one with the GROUP BY in the total, and the other one with count in the total, output is correct, x amount of female, x amount of male, the first row has the words FEMALE and MALE, the second row has the count of each. That is what I wanted.
However, if I add another field, let's say, HAND DOMINANCE, which would be "left", "right", and I use two more rows with GROUP BY and count in the total line, the output is
not correct, and it gives me all the records. If I add more fields where several results can come out, it keeps getting progressively worse.
I was trying to avoid running a query per field, it can get quite extensive.
Sincerely,
Mario
 
Since you new to access, I will advise you to make many queries first as you said group by gender count of gender
2) group by gender count of HAND DOMINANCE criteria "left"
3) group by gender count of HAND DOMINANCE criteria "right"
4) group by gender count of haircolor criteria "black"
5) group by gender count of haircolor criteria "red"
6) group by gender count of haircolor criteria "brown"
And so on then add all these queries to the first query and join on the gender field and select the count field of each query
when you get more proficient with queries you will start using subqueries
good luck
 
Read up on Crosstab Queries, starting with the Access On-line Help topic "About select and crosstab queries".

Crosstab queries are designed to do exactly what you are trying to do here - analyse data using two or more criteria.

HTH
Lightning
 
Pwise and Lightning,
thank you very much for your tips. Here is how i wound up doing it after trying both approaches.
I used the CROSSTAB query facility. I found it rather simple to use. Adding queries , which I assume is the APPEND query facility, turned out to be quite cumbersome,
after composing the query and "Joining" them, at execution time I got an error pointing to the JOIN's.
Once again, my appreciation for your help.
Sincerely,

SUPMRIO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top