count the number of unique records in a field within Access

  • Thread starter Thread starter Guest
  • Start date Start date
SELECT NameOfField, Count(*) AS HowMany
FROM TableName
GROUP BY NameOfField;
 
Here's an ECount() function that extends the functionality of the DCount()
in Access:
http://allenbrowne.com/ser-66.html

It includes an optional argument to ask for distinct count (i.e. number of
unique values in the specified field.)
 
Access does not support the DISTINCT predicate in the aggregate functions so
you have to build a Distinct query and then count

SELECT Count(*)
FROM
(SELECT Distinct FieldOne
FROM TableA) as UniqueFieldOne


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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

Similar Threads


Back
Top