Question : Subtotals in MS Access query

I need some help asap, if possible...

I am working on creating queries to output data into excel files. The query provides multiple groups of data (all numbers). I need to be able to provide a subtotal in the final output. Is this possible?

The query output should something like this.

      Field1      Field2      Field3      Field4      Field5
Group1                              
Group1                              
Group1                              
Group1                              
Group1                              
      Subtotals      Subtotals      Subtotals      Subtotals      Subtotals
Group2                              
Group2                              
Group2                              
Group2                              
      Subtotals      Subtotals      Subtotals      Subtotals      Subtotals
Group3                              
Group3                              
Group3                              
Group3                              
Group3                              
      Subtotals      Subtotals      Subtotals      Subtotals      Subtotals

Answer : Subtotals in MS Access query

You could create one query with the details.

SELECT Field1, Field2, .... FROM Table1.
Save as Query1

Then create another query with the subtotals.

SELECT Field1 & " Subtotal" As F1, Sum(Field2) As Field2, ... FROM Table 1.
Save as Query2

Then you could union the two queries.

SELECT Query1.* FROM Query1
UNION
SELECT Query2.* FROM Query2;

The result would be details and subtotals together on one query.
Random Solutions  
 
programming4us programming4us