I have some data grouped in a table by a certain criteria, and for each group it is computed an average —well, the real case is a bit more tricky— of the values from each of the detail rows that belong to that group. This average is shown in each group footer rows. Let's see this simple example:
What I want now is to show a grand total on the table footer. The grand total should be computed by adding each group's average (for instance, in this example the grand total should be 20 + 15 = 35). However, I can't nest aggregate functions. How can I do?
You just need to add the SUM() function in the table footer which is the outer scope of both groups and will sum them all together. If you are summing on a condition, you may need to put that in there also.