Solved

Microsoft Access - Counting Gender (Male/Female)

Posted on 2003-11-11
4
3,889 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

622 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