You can either sum the column in the query, or you can set a variable
and increment it as you loop over the query.

<cfquery name="queryname" dsn="dsnname">
select sum(invoiceamount) as invoicetotal from table
</cfquery>
<cfoutput> #queryname.invoicetotal#</cfoutput>

Or

<cfset variables.invoicetotal = 0>
<cfoutput>
<cfloop query="queryname">
<cfset variables.invoicetotal = variables.invoicetotal +
queryname.invoice amount>
</cfloop>
#variables.invoicetotal#
</cfoutput>
On Tue, Feb 24, 2009 at 9:46 AM, Rick Sanders <[email protected]> wrote:
>
> It's a newbie question so I'm posting it here.
>
>
>
> I've looked through the documentation and can't find it. How do I sum a
> column from a query?
>
>
>
> Ex:
>
>
>
> <cfoutput query=123>
>
> #invoiceamount#
>
> </cfoutput>
>
>
>
> Is there a sum function like: #sum(invoiceamount)# or anything like that?
>
>
>
> Thanks,
>
>
>
> Rick Sanders
>
> Webenergy
>
> Canada: 902-431-7279
>
> USA:       919-799-9076
>
> Canada: www.webenergy.ca
>
> USA:       www.webenergyusa.com
>
>
>
>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4399
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to