Hi there,
I have the following query:
SELECT tblUsers.ufName AS [Staff Name], Left([Forename],1) & "." & [surname] AS CKW1, tblUsers_1.ufName AS CKW2, 1 AS intC
FROM ((tblClients INNER JOIN tblCMRKWs ON tblClients.SBNo = tblCMRKWs.SBno) INNER JOIN tblUsers ON tblCMRKWs.KW1ID = tblUsers.userID) INNER JOIN tblUsers AS tblUsers_1 ON tblCMRKWs.KW2ID = tblUsers_1.userID
ORDER BY tblUsers.ufName;
Which returns similar results to below:
STAFF NAME CKW1 CKW2 intC
Clare J.Smith Elaine 1
Clare P.Jones Peter 1
Elaine A.Homes Peter 1
Elaine D.Roberts Clare 1
Elaine I.Hobbs Peter 1
Peter K.Sump Janet 1
Peter A.Smith Elaine 1
Peter A.Jones Clare 1
What i need is another column that counts the number of occurances of each staff name. So the results would be the same above but with an extra column as follows:
STAFF NAME CKW1 CKW2 intC countName
Clare J.Smith Elaine 1 2
Clare P.Jones Peter 1 2
Elaine A.Homes Peter 1 3
Elaine D.Roberts Clare 1 3
Elaine I.Hobbs Peter 1 3
Peter K.Sump Janet 1 3
Peter A.Smith Elaine 1 3
Peter A.Jones Clare 1 3
Is this possible using only 1 query or would i need to use another query or even a subquery?
Any help would be appreciated.
Dan
I have the following query:
SELECT tblUsers.ufName AS [Staff Name], Left([Forename],1) & "." & [surname] AS CKW1, tblUsers_1.ufName AS CKW2, 1 AS intC
FROM ((tblClients INNER JOIN tblCMRKWs ON tblClients.SBNo = tblCMRKWs.SBno) INNER JOIN tblUsers ON tblCMRKWs.KW1ID = tblUsers.userID) INNER JOIN tblUsers AS tblUsers_1 ON tblCMRKWs.KW2ID = tblUsers_1.userID
ORDER BY tblUsers.ufName;
Which returns similar results to below:
STAFF NAME CKW1 CKW2 intC
Clare J.Smith Elaine 1
Clare P.Jones Peter 1
Elaine A.Homes Peter 1
Elaine D.Roberts Clare 1
Elaine I.Hobbs Peter 1
Peter K.Sump Janet 1
Peter A.Smith Elaine 1
Peter A.Jones Clare 1
What i need is another column that counts the number of occurances of each staff name. So the results would be the same above but with an extra column as follows:
STAFF NAME CKW1 CKW2 intC countName
Clare J.Smith Elaine 1 2
Clare P.Jones Peter 1 2
Elaine A.Homes Peter 1 3
Elaine D.Roberts Clare 1 3
Elaine I.Hobbs Peter 1 3
Peter K.Sump Janet 1 3
Peter A.Smith Elaine 1 3
Peter A.Jones Clare 1 3
Is this possible using only 1 query or would i need to use another query or even a subquery?
Any help would be appreciated.
Dan