Re: totaling items in a recordset

2010-10-20 Thread Joel Black
You can query the database to extract the records you want, then query the query for a total. This example actually gets the total if there are multiple quantity for each item !--- get the totals --- cfquery dbtype=query name=total SELECT SUM(PriceSold*Quantity) AS TheTotal FROM cart /cfquery

Re: totaling items in a recordset

2010-10-20 Thread Michael Grant
You should read the rest of this thread Joel. On Wed, Oct 20, 2010 at 4:46 PM, Joel Black j...@blackbeardesign.comwrote: You can query the database to extract the records you want, then query the query for a total. This example actually gets the total if there are multiple quantity for

totaling items in a recordset

2010-10-19 Thread Rick Sanders
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

Re: totaling items in a recordset

2010-10-19 Thread John M Bliss
SUM() On Tue, Oct 19, 2010 at 2:18 PM, Rick Sanders c...@webenergy.ca 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

Re: totaling items in a recordset

2010-10-19 Thread David McGraw
Actually... the best way would be to use a query of queries... cfquery name=priceTotal dbtype=querySELECT 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.

RE: totaling items in a recordset

2010-10-19 Thread Rick Sanders
! Thanks, Rick -Original Message- From: David McGraw [mailto:david.mcg...@gmail.com] Sent: Tuesday, October 19, 2010 4:24 PM To: cf-talk Subject: Re: totaling items in a recordset Actually... the best way would be to use a query of queries... cfquery name=priceTotal dbtype=querySELECT SUM

Re: totaling items in a recordset

2010-10-19 Thread Michael Grant
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

Re: totaling items in a recordset

2010-10-19 Thread David McGraw
Yeah that's fine, yours works too, perhaps faster, but each way should not be noticeable unless your talking larger record sets, and then you should scrap everything and let the DB do it. Considering every time I need to get a total I typically need to loop around and display the items anyways,