Still don't feel entirely awake, so I might be missing something stupid, but for your main query you don't need GROUP BY unless your SELECT contains an aggregate for that query, which it doesn't.
(Your two aggregates, ConsumedVol and ProducedVol, are both in sub-queries, which would have their own GROUP BY if they needed it, but they don't since they're totals)
For the totalling bit of code... well, when you group on cfoutput you need an inner loop to do the more specific bit - and, more importantly, you need to ORDER BY the grouped bit first, otherwise you tend not to get what you're after.
So try this...
code:
<cfquery name="KilnsById" dbtype="query">
SELECT *
FROM Kilns
ORDER BY ruhId ASC
</cfquery>
<cfset TotalTotal = 0 />
<cfoutput query="KilnsById" group="ruhId">
<cfset InTotal = 0 />
<cfoutput>
<cfset InTotal += rudTotal />
</cfoutput>
<cfset TotalTotal += InTotal />
</cfloop>
Oh... except InTotal is needed for final table... so you probably actually want this:
code:
<cfquery name="KilnsById" dbtype="query">
SELECT *
FROM Kilns
ORDER BY ruhId ASC
</cfquery>
<cfset TotalTotal = 0 />
<cfset InTotal = [] />
<cfoutput query="KilnsById" group="ruhId">
<cfset InTotal[ruhId] = 0 />
<cfoutput>
<cfset InTotal[ruhId] += rudTotal />
</cfoutput>
<cfset TotalTotal += InTotal[ruhId] />
</cfloop>
Then do
#InTotal[ruhId]# in the final td bit.
Maybe.
I'm not entirely convinced I'm not completely overcomplicating things here.
:SEDITED: 10 May 2011 15:42 by BOUGHTONP