sorry i must be half asleep, you can use the sum function. so the full function 
would be

select sum(surcharge) from products
where productid in(<cfqueryparam value="theListOfProductIds#" 
list="yes" cfsqltype="cf_sql_varchar">)
and surcharge <> ""



> i think the best way would be to do this is directly through sql in 
> one query. you can build a list with the ids of all the products the 
> customer has selected, then in 1 query...
> 
> select surcharge from products
> where productid in(<cfqueryparam value="theListOfProductIds#" 
> list="yes" cfsqltype="cf_sql_varchar">)
> and surcharge <> ""
> 
> i am not sure but there must be a function in sql that adds up all the 
> values in a column - maybe someone else can suggest it - but this sql 
> statement then saves all the time that a loop would take and would 
> just return the results where those products you have entered have a 
> surcharge, then it is just a matter of adding it up. but as i said 
> there must be a sql function you can use within this same function to 
> do that
> 
> 
> > Hi
> > 
> > I am building a shopping cart which calculates shipping charges, 
> some 
> > products also have an additional surcharge. Which is where i am 
> stuck,
> > 
> > 
> > The additional surcharge is stored within the product table.
> > 
> > What i thought was to loop through the products in the cart,  query 
> 
> > the products database to get the surcharge or surcharges, loop 
> through 
> > the query results for the individual surcharges. If this is the 
> > correct way, how do i then add the surcharges up and account for 
> when 
> > the loop finishes.
> > 
> > Jason
> > 




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

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

Reply via email to