Pete - These numbers are what I get if I query a table in my db. How can I add ONLY the positive numbers and ignore the negatives?
-114.68
79.50
-8.48
2221.93
3994.88
-142.04
2655.45
-157.36
1084.00
-108.40
986.85
-58.48
15258.80
OK I'm having a hell of a time getting the summing to work, do you think you can assist?
I've attached the code and the output thus far.
Thanks!
<table cellpadding="2" align="center"> <tr> <td align="center"><font face="arial" size="4"><b>Kiln Number</b></font></td> <td align="center"><font face="arial" size="4"><b>Batch Date</b></font></td> <td align="center"><font face="arial" size="4"><b>Species</b></font></td> <td align="center"><font face="arial" size="4"><b>Footage In</b></font></td> <td align="center"><font face="arial" size="4"><b>Value In</b></font></td> <td align="center"><font face="arial" size="4"><b>Footage Out</b></font></td> <td align="center"><font face="arial" size="4"><b>Value Out</b></font></td> <td align="center"><font face="arial" size="4"><b>Variance</b></font></td> <td align="center"><font face="arial" size="4"><b>Absorption</b></font></td> <td align="center"><font face="arial" size="4"><b>MFG Variance</b></font></td> </tr> <!--- Loop the output and display it ---> <CFOUTPUT QUERY="kilns"> <cfset intotal = 0> <cfif rudTotal GT 0> <cfset intotal = intotal + rudTotal> </cfif> <!--- Set values in our variables ---> <TR> <td align="center"><font face="arial" size="4">#ruhID#</TD> <td align="center"><font face="arial" size="4">#DateFormat(ruhDate, "MM/DD/YYYY")#</TD> <td align="center"><font face="arial" size="4">#MID(rudProductID,6,2)#</TD> <td align="center"><font face="arial" size="4">#NumberFormat(ConsumedVol, ",")#</TD> <td align="center"><font face="arial" size="4">#intotal#</td> <td align="center"><font face="arial" size="4">#NumberFormat(ProducedVol, ",")#</TD> </TR> </CFOUTPUT> </TABLE>
CFOUTPUT QUERY="kilns" GROUP="ruhID"> <cfset intotal = 0> <cfif rudTotal GT 0> <cfset intotal = intotal + rudTotal> <cfset Total_Value_In = Total_Value_In + intotal> </cfif>
<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>
<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>
<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] /> </cfoutput>
<cfset InTotal = [] />
<cfset InTotal = {} />
Not a problem at all. It didn't work, but I'm taking a break and going to look at the SQL Reporting side of it for a bit. It has me confused and I need a break!
Thanks for your time!
Paeter most of my issue wasn't coding at all. My database contains both consumed and produced product. I only wanted to add consumed and ignore the produced.
Armed with that information I kicked it's ass and now have it adding what I want.
Appreciate you taking the time to whisper sweet nothings in my ear!