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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping Records and Count Them

Status
Not open for further replies.

ToshTrent

Technical User
Jul 27, 2003
209
Hi.

I have a smallish database where I would like to get a count of how many males and females are a member of my book club. Is there a way I can do this using a simple query?

Something like

Male = 18
Female = 25

When I do GroupBy Gender and Count I get multiple rows without giving an overall total.

Thank you in advance!

[red]
Thankyou[/red]
Matt
 
I've discovered this option

SELECT tblCustomerDetails.Gender, Count(*) AS HowMany FROM tblCustomerDetails GROUP BY tblCustomerDetails.Gender;

Is there a simpler method?

[red]
Thankyou[/red]
Matt
 
giving an overall total
SELECT Gender, Count(*) AS HowMany FROM tblCustomerDetails GROUP BY Gender
UNION SELECT 'Total', Count(*) FROM tblCustomerDetails
;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you!

[red]
Thankyou[/red]
Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top