R
ripper
I have Query1 that returns 2 fields:
CatID
Step1Decision
CatID can be 01 thru 29
Step1Decision can be N,X,P,D,R
Query1:
SELECT qryGrievances.CatID, qryGrievances.Step1Decision
FROM qryGrievances, qryStartEnd
Query2 uses Query1 joined to qryCategories to return all the categories and
their description plus those in Query1
Query2:
SELECT qryCategories.CatID, qryCategories.CatDesc, Query1.Step1Decision
FROM qryCategories LEFT JOIN Query1 ON qryCategories.CatID = Query1.CatID
Query3 uses Query2 in a crosstab so the Step1Decision (N,X,P,D,R) become
column headings and categories become rows, and adds a Total field:
Query3:
TRANSFORM Count(Query2.Step1Decision) AS [Count]
SELECT Query2.CatID, Query2.CatDesc, Count(Query2.CatID) AS Total
FROM Query2
GROUP BY Query2.CatID, Query2.CatDesc
PIVOT Query2.Step1Decision
Result looks like this:
CatID CatDesc Total <> D N R X
01 Accounting 7 6 1
02 Assignments 24 5 12 7
03 Conditions 1 0
04 Disciplinary 2 2
My questions are: how is the <> field generated? I can't refer to it in
code, which is a problem. Also, why does the total column show correct
totals for the D,N,R,X values added across, but if there are no records
returned for a category, it still shows 1? Also, if no records exist for one
of the decision values (P in the case above), that field is not returned by
the query at all. How can I create a report based on a query that may or may
not return some of the fields?
Thanks to all who can help!
Ripper
CatID
Step1Decision
CatID can be 01 thru 29
Step1Decision can be N,X,P,D,R
Query1:
SELECT qryGrievances.CatID, qryGrievances.Step1Decision
FROM qryGrievances, qryStartEnd
Query2 uses Query1 joined to qryCategories to return all the categories and
their description plus those in Query1
Query2:
SELECT qryCategories.CatID, qryCategories.CatDesc, Query1.Step1Decision
FROM qryCategories LEFT JOIN Query1 ON qryCategories.CatID = Query1.CatID
Query3 uses Query2 in a crosstab so the Step1Decision (N,X,P,D,R) become
column headings and categories become rows, and adds a Total field:
Query3:
TRANSFORM Count(Query2.Step1Decision) AS [Count]
SELECT Query2.CatID, Query2.CatDesc, Count(Query2.CatID) AS Total
FROM Query2
GROUP BY Query2.CatID, Query2.CatDesc
PIVOT Query2.Step1Decision
Result looks like this:
CatID CatDesc Total <> D N R X
01 Accounting 7 6 1
02 Assignments 24 5 12 7
03 Conditions 1 0
04 Disciplinary 2 2
My questions are: how is the <> field generated? I can't refer to it in
code, which is a problem. Also, why does the total column show correct
totals for the D,N,R,X values added across, but if there are no records
returned for a category, it still shows 1? Also, if no records exist for one
of the decision values (P in the case above), that field is not returned by
the query at all. How can I create a report based on a query that may or may
not return some of the fields?
Thanks to all who can help!
Ripper