I'd have to respectfully disagree. I think you'll find the way I proposed in
the other branch of this question is about 5 times faster than using query
of query.
QoQ is generally a poor choice.
Here's a test:
<cfset qry_test = QueryNew("intValue")>
<cfloop from="1" to="100" index="x">
<cfset QueryAddRow(qry_test)>
<cfset QuerySetCell(qry_test,'intValue',randRange(1,1000))>
</cfloop>
<cfoutput>
<cfset start = getTickCount()>
<cfloop from="1" to="5000" index="x">
<cfset temp = arraysum(listtoarray(valuelist(qry_test.intValue))) />
</cfloop>
ArraySum: #getTickCount()-start#
<br /><br />
<cfset start = getTickCount()>
<cfloop from="1" to="5000" index="x">
<cfquery name="priceTotal" dbtype="query">
SELECT SUM(intValue) as result FROM qry_test
</cfquery>
</cfloop>
QoQ: #getTickCount()-start#
</cfoutput>
On Tue, Oct 19, 2010 at 3:23 PM, David McGraw <[email protected]>wrote:
>
> Actually... the best way would be to use a query of queries...
>
> <cfquery name="priceTotal" dbtype="query">SELECT SUM(prices) as result FROM
> query</cfquery>
>
> <cfoutput>#priceTotal.result#</cfoutput>
>
> Again this is all assuming you don't want just the total and still need the
> individual items from the DB.
>
> Regards,
> David McGraw
> Oyova Software, LLC
> http://www.oyova.com
>
>
> On Tue, Oct 19, 2010 at 3:18 PM, Rick Sanders <[email protected]> wrote:
>
> >
> > Hey all. I am pulling prices from a database and want to total them. Is
> > there a function like #total(query.column)# ?
> >
> > Kind Regards,
> >
> >
> > Rick Sanders
> > Webenergy Software
> > 902-401-7689
> > http://www.webenergy.ca
> >
> >
> >
> >
> >
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338333
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm