SQL Distinct Count

I have data that I need to do a distinct count and I don't seem to be getting the right counts.

Sample of data:

Name, Role
John, PM
John, BA
Joe, PM
Joe, PM
John, BA

The results that I expect are
PM - 2
BA - 1

But I am not getting that.  I am getting
PM - 3
BA - 2

I am working in Access...Any thoughts?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hm thats because you group by the role; not by role/name

select role,[name],count(*) as cnt
from yourtable
group by role,[name]
tobey1Author Commented:
That Gives me the following:

role, name, cnt
BA, John, 2
PM, Joe, 2
PM, John, 1

The results needs to be
Role, Cnt
BA - 1
PM - 2
Jinesh KamdarCommented:
Whats the criteria to decide that the count for BA should be 1 ?
I would say the SQL is returning the correct figures but you need to get the records distinct before counting them

select role,count(*) as cnt
from (SELECT Role, Name FROM TableName GROUP BY Role, Name)
group by role

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tobey1Author Commented:
The criteria is, if a name holds the same role, then it is one, if a name holds 2 roles, then that is 1 for each role.  Same as if a there are 3 names for 1 role, then the role is 3.

Textreport Nailed It!

Thanks All.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.