View Single Post
  #4  
Old May 24th, 2010, 01:52 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Crosstab query totals

The reason the Total is 1 when there are no records in Step1Decision is you
are counting CatID in the SELECT clause. Try counting Step1Decision instead.


TRANSFORM Count(Query2.Step1Decision) AS [Count]
SELECT Query2.CatID, Query2.CatDesc, Count(Query2.Step1Decision) AS Total
FROM Query2
GROUP BY Query2.CatID, Query2.CatDesc
PIVOT Query2.Step1Decision IN ("D","N","R","X","P");

Of course, the Total count could still be off if there were any other values
in Step1decision other than Null, D, N, R, X, or P.

So you might even have to limit the query a bit further with a where clause.
TRANSFORM Count(Query2.Step1Decision) AS [Count]
SELECT Query2.CatID, Query2.CatDesc, Count(Query2.Step1Decision) AS Total
FROM Query2
WHERE Query2.Step1Decision IN ("D","N","R","X","P") OR Step1Decision is Null
GROUP BY Query2.CatID, Query2.CatDesc
PIVOT Query2.Step1Decision IN ("D","N","R","X","P");


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Duane Hookom wrote:
The is generated from one or more records with no value in
Step1Decision field.

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 IN ("D","N","R","X","P");