General discussion


I need a 'countif' equivalance in Access

By kosheno ·
Hi, I am trying to create a query where it will count the occurance of distinct elements in a column. Example: Column name is Question1, and its values can be any of the following: 'Excellent', 'Good', 'Fair', 'Poor'. I would like to run a query to see how many 'Exellent' has been entered, how many 'Good' has been entered and so forth. Only thing I could do is to write a single query for each element, which will be crazy because I have 35 of such question columns. Can someone please help me?????

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by illilli In reply to I need a 'countif' equiva ...

You need to do a query where you use the Group By statement something like follows:

SELECT tblYourTable.Question1Answer, Count(tblYourTable.Question1Answer) AS MyCount
FROM tblYourTable
GROUP BY tblYourTable.Question1Answer
ORDER BY tblYourTable.Question1Answer;

tblYourTable = The name of your table.
Question1Answer = The name of the field with your answers in it.

This is one of the most powerful SQL abilities of course, but a lot of people forget that you can put a count() of in the SELECT statement to get the number of occurrences.

By this time, you've probably figured this out though. Sorry for the late response.

Related Discussions

Related Forums