countif??

S

Steven Zillmer

<field-name> is the name of the yes/no field:

Select Count(<field-name>) as YesNoCount, <field-name>
from <table-name>
group by <field-name>
 
M

Michel Walsh

HI,


If you want two counts, one for the yes and another one for the no, you
can try:


SELECT COUNT(*), groupingField, yesNoField
FROM somewhere
GROUP BY groupingField, yesNoField


That make a different row for the yes and for the no. If you want the
count in a same line, you can run a crosstab over the previous query, or


SELECT ABS(SUM(yesNoField)) As SumOfYes, ABS(SUM(NOT yesNoField)) As SumOfNo
FROM somewhere
GROUP BY groupingField



based on the fact that a No is numerically equal to 0 and a default
value Yes is -1, in Jet (In fact, True is anything not null and not zero,
but by default, if generated by Jet, from a comparison test, as example, it
is a -1).



Hoping it may help,
Vanderghast, Access MVP
 

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