Count in a Query

J

Julie Gilliam

I have a database that I do audits in and the answers are either yes or no.
I was wondering how I could build a query with the Sum line to show number of
No's. The response for the report that I put out there yesterday worked but
it is very time consuming to set up formulas for each field. Thanks
 
G

golfinray

In your query criteria line, you can put Like No or possibly use an IIF
statement:
IIF([yourfieldname]="no","no","")
Or find Yes's and No's:
IIF([yourfieldname]="No","No","Yes")
 
J

John W. Vinson

I have a database that I do audits in and the answers are either yes or no.

If you have one field per question, your table design is WRONG and needs to be
reconsidered! How many yes/no fields are there? Are you encoding each question
in a fieldname? If so, consider normalizing into two tables: you should have a
one-to-many relationship to a table with one *record* for each answer, not one
*field*.
I was wondering how I could build a query with the Sum line to show number of
No's. The response for the report that I put out there yesterday worked but
it is very time consuming to set up formulas for each field. Thanks

Yes is stored as -1, No as 0 - so you can count Yesses with

=-Sum([yesnofield])

and Nos with

=Sum([yesnofield] + 1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top