Yes/No counting

F

Francois

I have a Field with Yes No values. I am strugling to create a querie where i
would like to count all the yes no fields and get a numerical value and then
count the yes values and no values seperately. Getting then three items Ex:
Total: 5 Yes Total: 3 and No Total: 2
 
K

Krzysztof Pozorek [MVP]

(...)
I have a Field with Yes No values. I am strugling to create a querie where
i
would like to count all the yes no fields and get a numerical value and
then
count the yes values and no values seperately. Getting then three items
Ex:
Total: 5 Yes Total: 3 and No Total: 2

SELECT Count(YesNoField) As Total,
-Sum(YesNoField) As YesTotal,
-Sum(Not YesNoField) As NoTotal
FROM Query1

K.P. MVP, Poland
www.access.vis.pl
 
J

JP COHEN

Francois said:
I have a Field with Yes No values. I am strugling to create a querie where
i
would like to count all the yes no fields and get a numerical value and
then
count the yes values and no values seperately. Getting then three items
Ex:
Total: 5 Yes Total: 3 and No Total: 2
 
P

Paul Shapiro

The count function returns the numbers of rows with non-null values for it's
argument. So Yes (-1 in Access) and No (0 in Access) will both be counted.
You can use the IIf function to return Null for the values you don't want to
count.

Count all rows: Count(*)
Count all rows with either Yes or No value entered in your field:
Count([YourFieldName])
Count Yes values: Count(iif([YourFieldName], 1, Null))
Count No values: Count(iif([YourFieldName], Null, 1))
 
B

bresolin.gerard

bonjour,je suis gerard de france mon travail et sur internet, et je doit
reconnaitre faire des heureux pour (e-mail address removed)
 

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