Solved

Microsoft Access - Counting Gender (Male/Female)

Posted on 2003-11-11
4
3,660 Views
Last Modified: 2006-11-17
How do you create a query that will count the amount of males in a class and the amount of females in a class and display them on a single query that displays CLASS NAME, GENDER, and NUMBER OF STUDENTS
0
Comment
Question by:MLaner9
4 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 125 total points
ID: 9729027
Drop this into the SQL view of a new query.


Select [Class name], [Gender], Count([lastname]) as NumberOfStudents
From MyTable
Group By [Class Name], [Gender]

Substitute you own table name and field to count

Pete

0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 9729213
Don't accept this as an answer.  I am using Pete's solution to make a list of student with gender totals on the top of list for class selected:

Select [Class name], [Gender] From MyTable Union Select "<Total (Male/Female):" As [Class name], DCount("*","MyTable","Gender='Male'") & "/" & DCount("*","MyTable","Gender=Female") As Gender From MyTable Where [Class name] = IIF(NZ(Forms!MyForm!txtClassName,"")<>"",[Class name],Forms!MyForm!txtClassName) Order By [Class name]

If you leave txtClassName on form MyForm blank, it will make list for all classes.

Mike
0
 
LVL 39

Expert Comment

by:stevbe
ID: 10025310
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: peter57r {http:#9729027}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

stevbe
EE Cleanup Volunteer
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question