Skip to main content
May 21, 2007
Question

QofQ error

  • May 21, 2007
  • 1 reply
  • 712 views
Hi i am getting a error of

Error Executing Database Query.

Query Of Queries runtime error.
The aggregate function [SUM(expression)] cannot operate on an operand of type [VARCHAR].

i have 2 columns in mysql database which are both DECIMAL fromats

i need to have a QofQ which i need but not sure how to change the queries to stop the error

<cfquery name="GetRecords" datasource="#application.ds#">
Select DateOfSM, RCODE, DAY(DateOfSM)as month3, OurCost, ClientCostPerSMS
FROM sms_records
WHERE MONTHNAME(DateOfSM)='#session.Daily#' AND YEAR(DateOfSM)=#session.DayYear#
</cfquery>

<cfquery name="GetRecords2" dbtype="query">
Select sum(OurCost)as TotalIncome, sum(ClientCostPerSMS)as Totalcost, month3
FROM GetRecords
GROUP BY month3
</cfquery>
This topic has been closed for replies.

1 reply

Inspiring
May 21, 2007
Which version of CF are you running? If 7+, try using the CAST() function
to force QoQ to understand the numeric cols are actually numeric. I'm not
sure why you'd need to do this, but QoQ works in mysterious ways,
sometimes.

--
Adam
May 22, 2007
how do i use the cast function to do this?