ssdanish
asked on
cfloop query help
sbennett gave me an awesome answer to my previous question about summarizing a line by line excel sheet with totals at the bottom. he gave me the code in the first block below. can someone (sbennett) help me actually put it in my actual code which I've pasted below his? i only need the Corp07 column totaled. thank you!!
<cfoutput>
<table>
<cfset MyTotal = "0">
<cfloop query="MyQuery">
<cfset MyTotal = MyTotal + MyQuery.DataColumn>
<tr>
<td>#MyQuery.DataColumn#</ td>
</tr>
</cfloop>
<tr>
<td>#MyTotal#</td>
</tr>
</table>
</cfoutput>
MY QUERY STARTS HERE
<cfquery name="campaign07" datasource="Pluto" dbtype="ODBC">
SELECT ORGACCOUNTNUMBER AS Oacct, ORGNAME1 AS Name, TP_ORG_CORP_34_2007_TOTAL AS Corp07
FROM dbo.DATAEXTRACTANDARCAMPAI GN2006S
ORDER BY EmplGoal DESC
</cfquery>
<cfheader name="Content-Disposition" value="inline;filename=Cam paignUpdat e.xls">
<cfcontent type="application/msexcel" >
<Table border="1" cellspacing="1">
<thead>
<tr>
<th><div align="left">Oacct</div></ th>
<th><div align="left">Name</div></t h>
<th><div align="left">Corp07</div>< /th>
</tr>
</thead>
<tbody>
<cfoutput query="campaign07">
<tr>
<td>#Oacct#</td>
<td>#Name#</td>
<td>#NumberFormat(Corp07," $99,999,99 9")#</td>
</tr>
</cfoutput>
</tbody>
<tfoot>
</tfoot>
</table>
<cfoutput>
<table>
<cfset MyTotal = "0">
<cfloop query="MyQuery">
<cfset MyTotal = MyTotal + MyQuery.DataColumn>
<tr>
<td>#MyQuery.DataColumn#</
</tr>
</cfloop>
<tr>
<td>#MyTotal#</td>
</tr>
</table>
</cfoutput>
MY QUERY STARTS HERE
<cfquery name="campaign07" datasource="Pluto" dbtype="ODBC">
SELECT ORGACCOUNTNUMBER AS Oacct, ORGNAME1 AS Name, TP_ORG_CORP_34_2007_TOTAL AS Corp07
FROM dbo.DATAEXTRACTANDARCAMPAI
ORDER BY EmplGoal DESC
</cfquery>
<cfheader name="Content-Disposition"
<cfcontent type="application/msexcel"
<Table border="1" cellspacing="1">
<thead>
<tr>
<th><div align="left">Oacct</div></
<th><div align="left">Name</div></t
<th><div align="left">Corp07</div><
</tr>
</thead>
<tbody>
<cfoutput query="campaign07">
<tr>
<td>#Oacct#</td>
<td>#Name#</td>
<td>#NumberFormat(Corp07,"
</tr>
</cfoutput>
</tbody>
<tfoot>
</tfoot>
</table>
ASKER
i messed up the first time and re-edited my question with the text below:
sbennett gave me an awesome answer to my previous question about summarizing a line by line excel sheet with totals at the bottom. he gave me the code in the first block below. can someone (sbennett) help me actually put it in my actual code which I've pasted below his? i only need the Corp07 column totaled. thank you!!
<cfoutput>
<table>
<cfset MyTotal = "0">
<cfloop query="MyQuery">
<cfset MyTotal = MyTotal + MyQuery.DataColumn>
<tr>
<td>#MyQuery.DataColumn#</ td>
</tr>
</cfloop>
<tr>
<td>#MyTotal#</td>
</tr>
</table>
</cfoutput>
MY QUERY STARTS HERE
<cfquery name="campaign07" datasource="Pluto" dbtype="ODBC">
SELECT ORGACCOUNTNUMBER AS Oacct, ORGNAME1 AS Name, TP_ORG_CORP_34_2007_TOTAL AS Corp07
FROM dbo.DATAEXTRACTANDARCAMPAI GN2006S
ORDER BY EmplGoal DESC
</cfquery>
<cfheader name="Content-Disposition" value="inline;filename=Cam paignUpdat e.xls">
<cfcontent type="application/msexcel" >
<Table border="1" cellspacing="1">
<thead>
<tr>
<th><div align="left">Oacct</div></ th>
<th><div align="left">Name</div></t h>
<th><div align="left">Corp07</div>< /th>
</tr>
</thead>
<tbody>
<cfoutput query="campaign07">
<tr>
<td>#Oacct#</td>
<td>#Name#</td>
<td>#NumberFormat(Corp07," $99,999,99 9")#</td>
</tr>
</cfoutput>
</tbody>
<tfoot>
</tfoot>
</table>
sbennett gave me an awesome answer to my previous question about summarizing a line by line excel sheet with totals at the bottom. he gave me the code in the first block below. can someone (sbennett) help me actually put it in my actual code which I've pasted below his? i only need the Corp07 column totaled. thank you!!
<cfoutput>
<table>
<cfset MyTotal = "0">
<cfloop query="MyQuery">
<cfset MyTotal = MyTotal + MyQuery.DataColumn>
<tr>
<td>#MyQuery.DataColumn#</
</tr>
</cfloop>
<tr>
<td>#MyTotal#</td>
</tr>
</table>
</cfoutput>
MY QUERY STARTS HERE
<cfquery name="campaign07" datasource="Pluto" dbtype="ODBC">
SELECT ORGACCOUNTNUMBER AS Oacct, ORGNAME1 AS Name, TP_ORG_CORP_34_2007_TOTAL AS Corp07
FROM dbo.DATAEXTRACTANDARCAMPAI
ORDER BY EmplGoal DESC
</cfquery>
<cfheader name="Content-Disposition"
<cfcontent type="application/msexcel"
<Table border="1" cellspacing="1">
<thead>
<tr>
<th><div align="left">Oacct</div></
<th><div align="left">Name</div></t
<th><div align="left">Corp07</div><
</tr>
</thead>
<tbody>
<cfoutput query="campaign07">
<tr>
<td>#Oacct#</td>
<td>#Name#</td>
<td>#NumberFormat(Corp07,"
</tr>
</cfoutput>
</tbody>
<tfoot>
</tfoot>
</table>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, that should work. You may want to add a description to the total line like this:
MY QUERY STARTS HERE
<cfquery name="campaign07" datasource="Pluto" dbtype="ODBC">
SELECT ORGACCOUNTNUMBER AS Oacct, ORGNAME1 AS Name, TP_ORG_CORP_34_2007_TOTAL AS Corp07
FROM dbo.DATAEXTRACTANDARCAMPAI GN2006S
ORDER BY EmplGoal DESC
</cfquery>
<Table border="1" cellspacing="1">
<thead>
<tr>
<th><div align="left">Oacct</div></ th>
<th><div align="left">Name</div></t h>
<th><div align="left">Corp07</div>< /th>
</tr>
</thead>
<cfset myTotal = 0>
<tbody>
<cfoutput query="campaign07">
<tr>
<td>#Oacct#</td>
<td>#Name#</td>
<td>#NumberFormat(Corp07," $99,999,99 9")#</td>
</tr>
<cfset myTotal = myTotal + Corp07>
</cfoutput>
</tbody>
<tfoot>
<cfoutput>
<tr><th align="right" colspan="2">Total:</th>
<th>#NumberFormat(myTotal, "$99,999,9 99")#</th>
</tr>
</cfoutput>
</tfoot>
</table>
MY QUERY STARTS HERE
<cfquery name="campaign07" datasource="Pluto" dbtype="ODBC">
SELECT ORGACCOUNTNUMBER AS Oacct, ORGNAME1 AS Name, TP_ORG_CORP_34_2007_TOTAL AS Corp07
FROM dbo.DATAEXTRACTANDARCAMPAI
ORDER BY EmplGoal DESC
</cfquery>
<Table border="1" cellspacing="1">
<thead>
<tr>
<th><div align="left">Oacct</div></
<th><div align="left">Name</div></t
<th><div align="left">Corp07</div><
</tr>
</thead>
<cfset myTotal = 0>
<tbody>
<cfoutput query="campaign07">
<tr>
<td>#Oacct#</td>
<td>#Name#</td>
<td>#NumberFormat(Corp07,"
</tr>
<cfset myTotal = myTotal + Corp07>
</cfoutput>
</tbody>
<tfoot>
<cfoutput>
<tr><th align="right" colspan="2">Total:</th>
<th>#NumberFormat(myTotal,
</tr>
</cfoutput>
</tfoot>
</table>
What is your question?