count groups of entries

  • Thread starter Thread starter Gerhard
  • Start date Start date
G

Gerhard

Hello,

I have a database table like this:

Proj_Number Name Task
10 Jack 1
20 Jack 1
30 Jack 1
30 Jack 2
35 Jack 1
10 John 3
25 John 3
45 Ken 4
....

I now would like to have a SQL query which gives me the number of
projects per person, like this:

Jack 4
John 2
Ken 1

The tricky part is that there might be lines with the same project
number but different task number (as you see for Proj_number 30). I
want only the number of projects that a person works on, not regarding
on how many tasks he/she works.
How can I do this?

Thanks,
Gerhard.
 
Create 2 Queries:

Query1:

SELECT DISTINCT Table1.[Name], Table1.[Proj_Number]
FROM Table1

Query2:

SELECT Query1.[Name], Count(Query1.[Proj_Number]) AS ProjCount
FROM Query1
GROUP BY [Name]

Second Query should give what you want.

You can combine 2 Queries into one.
 

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

Similar Threads

Need Query Help 0
Restarting Record Count in a Query 2
Counting text 2
Combining rows 14
Unique Query Dilema 13
Query Question 6
Count with a twist 1
WCG Stats Wednesday 16 August 2023 3

Back
Top