If you just need  the output just use the first query and do this :
<cfoutput>#ArraySum(rstest['myPrice'])#

> Oh Thanks
> I found a very good way thanks to builderau (
> http://www.builderau.com.
> au/architect/database/soa/Query-of-Queries-in-ColdFusion-MX/0,
> 339024547,320275211,00.htm
> )
> I found an easy way.
> I leave my code here for others who have the same problem. It uses 
> Query of
> queries. An easy and awesome way to make more complicated queries with 
> no
> confusion.
> 
> <!--- here is the basic query which has some conditions and 
> filterations.
> Don't worry there is no need to make things more complicated here 
> --->
> <cfquery name="rstest" datasource="#Request.DSN#">
> SELECT Tbl_Users.UserID,
     
> Tbl_Users.UserName,
     
> Tbl_Users.FistName,
     
> Tbl_Users.LastName,
     
> Tbl_AccOrders.OrederID,
     
> Tbl_AccOrders.UserID,
     
> Tbl_AccOrders.PrID,
     
> Tbl_AccOrders.Price as myprice,
     
> Tbl_Accessories.PrID,
     
> Tbl_Accessories.PrNumber,
     
> Tbl_Accessories.PrName,
     
> Tbl_Accessories.PrPrice
> FROM Tbl_Users Tbl_Users,
     
> Tbl_AccOrders,
     
> Tbl_Accessories
> WHERE Tbl_Users.UserID = Tbl_AccOrders.UserID
        
> AND Tbl_Accessories.PrID = Tbl_AccOrders.PrID
> </cfquery>
> 
> <!--- yes here it is, the query of above query. It makes things easier. 
> Now
> I can use the simplest SQL statements to make things clear to  
> calculate the
> total of all the order prices or other things --->
> 
  
> <cfquery name="testme" dbtype="query">
> SELECT
> sum(myprice) as pricetotal
> from
> rstest
> </cfquery>
> 
> <!--- here I output the total price for all orders --->
> <cfoutput>#testme.pricetotal#</cfoutput>
> 
> 
> On Fri, Mar 7, 2008 at 4:51 PM, Dominic Watson <
> [EMAIL PROTECTED]> wrote:
> 
> > SELECT SUM (Donation) as donationsTotal FROM table_donations
> >
> > Do a google on TSQL Aggregate Functions to get more samples of stuff 
> like
> > this (Max, Min, etc)
> >
> > HTH
> >
> > Dominic
> >
> > --
> > Blog it up: http://fusion.dominicwatson.co.uk
> >
> >
> > 


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

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300733
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to