Forum Discussion
Crosstab Query Totals
- talmrubin2Jan 08, 2021Copper Contributor
George_HepworthAfter I run the cross tab query, i need to press the 'Totals' button at the top each time. Is there a way to default so that the it totals when i run the query?
- George_HepworthJan 08, 2021Silver Contributor
Thanks for clarifying. Not that I know of. However, I would not do it that way anyway.
I would do this as a UNION query.
The first SELECT in the UNION is as you have it know.
Then UNION and a second SELECT that does the totals by NOT grouping on Delivery Te? and Shipping Code. I would need to see the actual SQL from your crosstab to attempt an example. However, where you have SELECT [Delivery Te?], you would use "Totals" AS [Delivery Te?], and where you have [Shipping Code*], you would use "" AS [Shipping Code*] to suppress the Grouping on those fields but still have a placeholder value to display.
If you need more details, please provide the actual SQL from the Crosstab query to work with.- talmrubin2Jan 08, 2021Copper Contributor
George_HepworthThanks! below is the sql, any help would be appreciated. I am going to play around with this myself also
TRANSFORM Count(Past_Due_Data.[Order No]) AS [CountOfOrder No]
SELECT Past_Due_Data.[Delivery Terms], Past_Due_Data.[Shipping Code*]
FROM Past_Due_Data INNER JOIN Plant_Lookup ON Past_Due_Data.Site = Plant_Lookup.[Plant Number]
GROUP BY Past_Due_Data.[Delivery Terms], Past_Due_Data.[Shipping Code*]
PIVOT Plant_Lookup.[Plant Name];