Home >Database >Mysql Tutorial >How to Count Unique Values in an Access Query?

How to Count Unique Values in an Access Query?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2025-01-12 09:38:43188browse

How to Count Unique Values in an Access Query?

Calculating Unique Entries in Access Queries

Standard Access Count(*) functions can't directly handle unique value counts. To accurately count distinct entries within a specific field, a modified query is required.

The following query demonstrates how to obtain a distinct count of the "Name" field from the "table1" table:

<code class="language-sql">SELECT Count(*) AS N
FROM
(SELECT DISTINCT Name FROM table1) AS T;</code>

This approach leverages a subquery to initially extract unique "Name" values. The outer query then counts the rows from this subquery's result set, yielding the correct unique count.

The above is the detailed content of How to Count Unique Values in an Access Query?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn