Skip to main content
July 24, 2008
Answered

math

  • July 24, 2008
  • 1 reply
  • 262 views
I am trying to do some simple math equations with data from a query. This is
what it may look like.

#queryname.VariableA*#(#queryname.VariableB#/#queryname.VariableC#) Is there
any ideas?

I can get these to work when setting them within a query of query but when I loop the variables they populate every value with its associated column. Here is the example:

<CFQUERY NAME="GetEarned" DBTYPE="query">
SELECT
TaskDesc.QTYComplete AS QTYComplete,
TaskDesc.Manhours AS Manhours,
(TaskDesc.Manhours *(TaskDesc.QTYComplete / TaskDesc.QTY)) AS Earned,
(TaskDesc.QTYComplete / TaskDesc.QTY) AS PercentComplete
FROM TaskDesc
</CFQUERY>


------------------------------------------
<!--- Add JSA Task --->
</TR><br>
<CFLOOP QUERY="TaskDesc" startrow="#URL.StartRow#" endrow="#EndRow#"><cfoutput>
<TR>
<!--- Cust name --->
<TD><table width="550" border="1" bordercolor="FFFFFF" cellspacing="0" cellpadding="0">
<tr>
<td width="100" align="center"><font size="-1">#ActivityID#</font></td>
<td width="200" align="center"bgcolor="FFFFFF"><font size="-2">#ActivityDescription#</font></td>
<td width="50" align="center"><font size="-2">

<cfif GetEarned.QTYComplete IS "0">0
<cfelse>#GetEarned.Earned#</cfif>

</font></td>
<td width="50" align="center"><font size="-2">#Manhours#</font></td>
<td width="50" align="center"bgcolor="FFFFFF"><font size="-1" color="006633">

<cfif GetEarned.QTYComplete IS "0">0
<cfelse>#GetEarned.PercentComplete#</cfif>

</cfoutput></cfloop>

I did get rid of some html code to clean it up a bit.
    This topic has been closed for replies.
    Correct answer
    Sometimes I can't see the forest through the trees! My loop was looping the main query no the query of the main. Thanks for the help

    1 reply

    Inspiring
    July 24, 2008
    It would be simpler to add the math to the original query. Your q of q shows that you know how to do this.
    Correct answer
    July 24, 2008
    Sometimes I can't see the forest through the trees! My loop was looping the main query no the query of the main. Thanks for the help