Discussion Locked

I need a 'countif' equivalance in Access

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
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?????

1 reply

by illilli

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.

This discussion is closed to new replies.