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
Release: 2025-01-12 09:38:43
Original
186 people have browsed it

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template