Can you post your attempt at using SUM( )?

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2003 2:06 PM
To: CF-Talk
Subject: RE: Quick SQL Sum Question


I need the sum...I am trying to get the total of additional shipping from
the products being returned.  It is a money datatype, so should be fine.
But I can't use SUM() alone...

Eric

-----Original Message-----
From: Mark A. Kruger - CFG [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2003 8:45 AM
To: CF-Talk

To use SUM( ) the column in question MUST be numeric type (int, decimal,
float etc).   Are you sure you are not trying to get a "count" rather than a
sum?   A sum totals all the columns together while a count (select
count(blah) as cBlah)  tells you the number of rows.

-Mark

-----Original Message-----
From: Andrew Golden [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2003 8:27 AM
To: CF-Talk
Subject: Re: Quick SQL Sum Question


At 03:27 PM 8/12/2003 -0500, you wrote:
>How can I easily nab the SUM of the inventory.service_shipping records
>returned in this query via SQL?   SUM blah AS cblah tosses an error, I
>suppose because just one part is aggregate?  Any quick ideas?

Have you tried SUM(blah) AS cblah? Sometimes odd little syntax errors have
driven me crazy for hours on end because they have worked differently
before...Just a thought. One other option(albeit not as efficient) is to set
a variable and loop through the query...I.E.

<cfquery name="get_productHOLDS" datasource="sddheinz"> SELECT
customer_orders_prod_shiphold.product_id,
customer_orders_prod_shiphold.qty,
customer_orders_prod_shiphold.line_total,
customer_orders_prod_shiphold.order_id,
inventory.service_name,
inventory.service_shipping,
inventory.service_desc
FROM customer_orders_prod_shiphold
LEFT OUTER JOIN inventory on
customer_orders_prod_shiphold.product_id = inventory.service_id WHERE
customer_orders_prod_shiphold.order_id = <cfqueryparam
cfsqltype="cf_sql_integer" value="#order_id#"> </cfquery>

<cfset sum = 0>
<cfloop query="get_productHOLDS">
         <cfset sum = sum + service_shipping> </cfloop>


Good luck!

Andrew Golden





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to