Reputation: 19
I have a recordset, I want to count how many different values has a "column" of that recordset.
In a SQL query it would be something like that:
SELECT COUNT(tag)
FROM x
GROUP BY tag
Where x would be the recordset and tag would be the "column"
For example, if tag is: y1,y1,y1,y2,y3,y3,y4,y4,y5 I want to get 5, since there are 5 different values for tag.
The problem is that I can't execute a SQL query to the recordset.
Upvotes: 1
Views: 1118
Reputation: 1270773
You are looking for count(distinct)
:
SELECT COUNT(DISTINCT tag)
FROM x;
MS Access doesn't support this standard functionality, so you can use a subquery:
SELECT COUNT(tag)
FROM (SELECT DISTINCT tag FROM x) as xx
Upvotes: 3