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

Count Records based on value

Status
Not open for further replies.

PavelowFE

Technical User
Jan 13, 2009
39
US
Hi,
I'm trying to get my query to count the number of records based on the value (text) that it contains. Here's what I have so far:

SELECT Sum([# of Operators Trained]) AS [Total Operators Trained], Sum([# of Aircrew Trained]) AS [Total Aircrew Trained], Count([Type of Tng])
FROM [Mission Report]
WHERE ([Mission Report].[Date Tng Completed] Between #10/1/2008# And #9/30/2009#)

I'm having trouble figuring out the Count part. Right now it counts all of the records, but how do I get it to count only records that contain a particular text (i.e. JCAS).
 
Replace this:
Count([Type of Tng])
with this:
Sum(IIf([Type of Tng]='JCAS',1,0))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Awesome! Worked great. Thank you. I knew it was something simple, but it was just kicking my butt.

Vince
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top