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

Count based on multiple criteria

Status
Not open for further replies.

IKinal

Technical User
Apr 14, 2003
32
US
Hi,

I need a count based on two criteria in my table, such as a count of everyone where sex=2 and category=1. Is this possible in an Access query?

Thanks,
I. Kinal
 
yes.

create a new query
choose your table
select the 3 fields everyone, sex, and category
click the Sigma icon to get the Total row
in the Total row set the everyone field to Count
in the Total row set the Sex and Category fields to Where
enter 2 in the sex criteria and 1 in the category criteria

the SQL looks like this:

SELECT Count(TableName.Everyone) AS CountOfEveryone
FROM TableName
WHERE (((TableName.Sex)=2) AND ((TableName.Category)=1));

hope this helps you.
 
Try this:

Select Count(*) as CountOfRecords
FROM tblYourTableName as A
WHERE A.Sex = 2 and A.Category = 1;

Just update the red code with your table name, copy and paste into the SQL window of a new query. Let me know if you have any other questions.

Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Thank you both for the help - problem solved!

I. Kinal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top