Web Development



Advanced count query

By jimmy-jam ·
Hello all. I'm trying to figure out a way to run some type of query against my Access Database in which I can count the number of time a distinct string shows up.

I tried

select count(ColumnName) from tableName where ColumnName like %string%

Apparently you can't do that. Can anyone offer some suggestions as to how I may accomplish this? I only need it to return a number.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Would it be something like this?.

Access: Count Function

In Access, the Count function returns the number of records in a select query.

The syntax for the Count function is:

Count( expression )

expression can be a field or any string expression.


You can use the Count function in a query by clicking on the Totals button in the toolbar (This is the button with the summation symbol). The Count function is used in conjunction with the Group By clause.

This query would return the number of records for each ProductName. You can actually substitute any field with the Count function and it will return the same count result. In this case, we've used the SupplierID field to determine the number of records for each ProductName.

Please post back if you have any more problems or questions.

Related Discussions

Related Forums