Why not use a SUM aggregate function on the database?
Kevin
>>> [EMAIL PROTECTED] 03/01/01 01:58PM >>>
Hi,
Can someone suggest a better way to sum a numeric column in a query?
The
solution is probably painfully simple, but I've been struggling for an
hour
or two on it (only have online docs available).
<CFOUTPUT>#ArrayDeleteAt(GetHours,1)#</CFOUTPUT>
<CFLOOP query="getMainList">
<CFOUTPUT>#ArrayAppend(GetHours,
"#numberformat(hours)#")#</CFOUTPUT>
</CFLOOP>
Line 3 produces a string of "YES"s at the top of my output- one for
every
record in the query.
The following gives me the result I need, but I can't get around the
display of the YES's that appears.
<cfset cost = ArraySum(GetHours)*65>
<CFOUTPUT>
<P>The sum of the numbers is #ArraySum(GetHours)# hours. At
$65/hr,
this equals #dollarformat(cost)#
</CFOUTPUT>
TIA,
--John
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists