0
我有一個查詢:CF8 - 沁在一個循環
<cfquery name="getDesc" datasource="#ds#">
SELECT
desc,
SUM(charge) as cost,
COUNT(*) as cnt
FROM
product
WHERE Length(desc) > 0
</cfquery>
然後填充表:
<table>
<tbody>
<tr>
<th>Description</th>
<th>Amount of Charges</th>
<th>Cost (£)</th>
</tr>
<cfoutput query="getDesc">
<tr>
<td>
#HTMLEditFormat(getDesc.desc)# <br />
</td>
<td>
#HTMLEditFormat(getDesc.cnt)# <br />
</td>
<td>
#HTMLEditFormat(getDesc.cost)# <br />
</td>
</tr>
</cfoutput>
</tbody>
</table>
我的問題是,我想表中的兩行合併是具有相同的價值,並且也將它們的計數加在一起。
到目前爲止,我有:
<table>
<tbody>
<tr>
<th>Description</th>
<th>Amount of Charges</th>
<th>Cost (£)</th>
</tr>
<cfoutput query="getDesc">
<tr>
<cfif getDesc.desc EQ 'No Charge' OR getDesc.desc EQ 'No Charge (2)'>
<td>
No Charge & (2)
</td>
<td>
<cfset cntSum = arraySum(getDesc['cnt'])>
#cntSum#
</td>
<cfelse>
<td>
#HTMLEditFormat(getDesc.desc)# <br />
</td>
<td>
#HTMLEditFormat(getDesc.cnt)# <br />
</td>
</cfif>
<td>
#HTMLEditFormat(getDesc.cost)# <br />
</td>
</tr>
</cfoutput>
</tbody>
</table>
但是這給了我的兩行「不收費&(2)」和計數表中的行的所有其餘的總和,而不是僅僅我想要的兩排。
希望這是有道理的。
尼斯巴尼。你的個人資料有點稀疏。我想看看你的網站。想想看,我只是搬了我的,我的個人網站是不存在的。嗯......我想我知道今天剩下的時間我會做什麼! –