sum of groups

  • Thread starter Thread starter dan
  • Start date Start date
D

dan

In wizard it does not allow me to request a sum of groups
(unless I'm missing something).
If this is true, what sql input can I make to get a sum of
my groups.
I want to total daily orders.
Thank you.
 
Dear Dan:

I assume from this you already have a query that gives you group
totals. Except for an advanced SQL Server ROLLUP query, you are only
going to get these totals from a simple query.

You could, however, create a "Grand Total" query, make a UNION of the
two, and sort the results so the Grand Total comes last using an added
column:

SELECT 0 AS GroupLevel, MyGroup, SUM(SomeValue) AS GroupTotal
FROM MyTable
GROUP BY MyGroup
UNION ALL
SELECT 9 AS GroupLevel, "Grand Total" AS MyGroup,
SUM(SomvValue) AS GroupTotal
FROM MyTable
ORDER BY GroupLevel, MyGroup

This assumes that MyGroup is text.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
Back
Top