Count distinct value

B

Boon

Hi,

I am creating a query that I want it to count a distinct value.

See this table below:

Name Item
a mm
b nn
a mm
a kk
a nn
b mm
b kk


I want to create a total query that group by Name and Count Item. But, I
don't want it to count the duplicate record.

Basically I want the result to be

a 3
b 3

Thanks a lot.
Boon
 
N

ND Pard

Copy and Paste the following SQL into your query.

SELECT A.Name, Count(A.Name) AS Name_Count
FROM (SELECT DISTINCT [YourTableName].[Name], [YourTableName].Item FROM
[YourTableName]) AS A
GROUP BY A.Name;


Good Luck
 

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

Top