Skip to main content
Inspiring
April 4, 2013
Answered

Q of Q round number issue

  • April 4, 2013
  • 2 replies
  • 761 views

Hi All,

I cannot use round function in Query of Query. I can cast the number as integer like:

<cfquery dbtype="query">

     select cast(myValue as integer) finalNumber

     from myQuery

</cfquery>

where myValue = 65.7, but the result is 65, it should be 66.

It is a work around this issue?

Thanks!

    This topic has been closed for replies.
    Correct answer Dan_Bracuk

    select a static field in your q of q.  Then loop through the results and update it using querysetcell and the coldfusion round() function.

    2 replies

    Inspiring
    April 4, 2013

    No, the integer part of 65.7 is 65, not 66. casting to an integer is not a rounding operation, it's a data-type conversion operation. If you want to do rounding, add 0.5 to the float before converting it to an int.

    --

    Adam

    Dan_BracukCorrect answer
    Inspiring
    April 4, 2013

    select a static field in your q of q.  Then loop through the results and update it using querysetcell and the coldfusion round() function.

    jfb00Author
    Inspiring
    April 4, 2013

    Here is my code solution Dan:

         <cfloop from="1" to="#totalYears#" index="y">

                <cfset tempYear = qryResult["year_" & #y#] />

                <cfset QuerySetCell(firstQuery, "year_#y#", round(tempYear))>

            </cfloop>

    Thanks!