Group and Count field values

Baldrick

Registered User.
Local time
Yesterday, 22:33
Joined
Jul 2, 2001
Messages
35
I have 3 fields that I'm trying to query. They are LOB, DIV and Project_Stat_Code. I am trying to count 4 values in Project_Stat_Code ("IP", "OH", "PD" and "C") and Group them by LOB, then by DIV.

I'm not sure how to approach this. Should I generate a single query for each Project_Stat_Code value and then query against those queries? Or, can I do it all in a single query?
 
SELECT LOB, DIV, Count(Project_Stat_Code) AS CountOfProject_Stat_Code
FROM [TableName]
GROUP BY LOB, DIV;

HTH,

Edward
 
Thanks Edward

What I actually needed was a crosstab:

TRANSFORM Count(qryProjectStatus.Project_Stat_Code) AS CountOfProject_Stat_Code
SELECT qryProjectStatus.LOB, qryProjectStatus.Div
FROM qryProjectStatus
GROUP BY qryProjectStatus.LOB, qryProjectStatus.Div
PIVOT qryProjectStatus.Project_Stat_Code;

For the benefit of others...
 

Users who are viewing this thread

Back
Top Bottom