You need to determine how you want the amounts to be grouped, then only
specify those columns in the SELECT and GROUP BY lists.

The more columns you add, the less-grouped your results may be.  It all
depends on the uniqueness of the field values for each column returned.

Start out by SELECTing only a.accountDebits and SUM(a.accountDebits).
(Make sure you specify only a.accountDebits in the GROUP BY, however.)

Then, CFDUMP the results.

Then, add a column, one at a time, until you see the results you need.
At this point, each column you add to the SELECT list must be added to
the GROUP BY list.

M!ke 

-----Original Message-----
From: Roberto Perez [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 20, 2006 8:20 AM
To: CF-Talk
Subject: Re: SUM within general QUERY

At 09:04 AM 8/20/2006, Jochem van Dieten wrote:

>SELECT
>   a.accountID,
>   a.accountName,
>   a.accountDebits,
>   SUM(a.accountDebits) AS TotalSpent
>FROM
>   account_tb a
>WHERE
>   a.accountID = 222222
>GROUP BY
>   a.accountID,
>   a.accountName,
>   a.accountDebits


Thank you for a prompt response. I tried that by now my TotalSpent
variable shows each individual expense next to the other in an
continuous string:

100100100200100300100

.....instead of the mathematical sum of those amounts. Is that related to
the GROUP part? What does the GROUP BY do in this case (I'm assuming it
is not related to the GROUP that you use to arrange output)?

Thanks,

Roberto 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250406
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