Roberto Perez wrote:
>
> SELECT
>   a.accountID, a.accountName, a.accountDebits,
>   SUM(a.accountDebits) AS TotalSpent
> FROM account_tb a
> WHERE a.accountID = 222222
> 
> ...but CF tells me: "You tried to execute a query that does not 
> include the specified expression 'accountID' as part of an aggregate 
> function."

That is not a CF error message, but an error message from the database.


> My only solution so far has been to execute the SUM operator in a 
> separate query. So my question is: can we use SUM within a general 
> query that gets other data too, or does SUM have to go in its own 
> query?

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

Jochem

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:250400
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