嗨,我正在努力做到以下几点:
代码用ASP编写,输出来自数据库。我试图将QTY和RATE#2相乘并显示返回数据中每个订单的总数。这与输出中的最后一个td有关。
<td align="center" height="30"><%= rowCrossHire("NLCODE") %></td>
<td align="center" height="30"><%= rowCrossHire("QTY") %></td>
<td align="center" height="30"><%= rowCrossHire("QTYRETD") %></td>
<td align="center" height="30"><%= formatcurrency(rowCrossHire("RATE#1"), 2) %></td>
<td align="center" height="30"><%= need to add "QTY" * "RATE#1" here %></td>
还有其他要求请告诉我 提前致谢 大卫
<table>
<%
crosshireSQL = "SELECT CONTITEMS.CONTNO, CONTITEMS.ITEMDESC, CONTITEMS.ITEMDESC#2, CONTITEMS.RATE#1, CONTITEMS.ITEMDESC#3, CONTITEMS.ITEMNO, CONTITEMS.NLCODE, CONTITEMS.QTY, CONTITEMS.QTYRETD, CONTITEMS.STATUS, CONTRACTS.ACCTNAME FROM CONTITEMS INNER JOIN CONTRACTS ON CONTRACTS.CONTNO = CONTITEMS.CONTNO WHERE CONTITEMS.NLCODE IN ('4001') AND CONTITEMS.STATUS = 1 ORDER BY CONTITEMS.CONTNO ASC, CONTITEMS.ITEMNO ASC"
set rowCrossHire = returnRecordSet(crosshireSQL)
currentContract = ""
if not rowCrossHire.eof then
' cross hires found
do while not rowCrossHire.eof
' loop through cross hires
if currentContract <> rowCrossHire("CONTNO") then
' new contract
%>
<tr class="contract">
<th colspan="11"> </th>
</tr>
<%
currentContract = rowCrossHire("CONTNO")
end if
sonNo = "Pre SONs"
sonSQL = "SELECT SONID, SONRevision FROM SONs WHERE SONContractNo LIKE '%" & rowCrossHire("CONTNO") & "%' ORDER BY SONID ASC LIMIT 1"
set rowSON = returnRecordSetOnline(sonSQL)
if not rowSON.eof then
' son found
sonRevision = ""
if cint(rowSON("SONRevision")) > 0 then
' son revision found
sonRevision = chr((cint(rowSON("SONRevision")) + 96))
end if
sonNO = "<a href=""http://admin.boilerrentalservices.co.uk/sons/list/view-menu.php?SONID=" & rowSON("SONID") & """ target=""_blank"" title=""View " & rowSON("SONID") & sonRevision & """>" & rowSON("SONID") & sonRevision & "</a>"
end if
itemDescription = rowCrossHire("ITEMDESC")
if trim(rowCrossHire("ITEMDESC#2")) <> "" then
' additional description
itemDescription = itemDescription & ", " & rowCrossHire("ITEMDESC#2")
end if
if trim(rowCrossHire("ITEMDESC#3")) <> "" then
' additional description
itemDescription = itemDescription & ", " & rowCrossHire("ITEMDESC#3")
end if
%>
<tr>
<td height="30"><a href="/dashboard-fullscreen/individual/contracts/view.asp?Allow=f875eba085941cc78509bd3482dc0294&Contract=<%= rowCrossHire("CONTNO") %>" target="_blank" title="View <%= rowCrossHire("CONTNO") %>"><%= rowCrossHire("CONTNO") %></a></td>
<td height="30"><%= sonNo %></td>
<td height="30"><%= rowCrossHire("ACCTNAME") %></td>
<td height="30"><%= rowCrossHire("ITEMNO") %></td>
<td height="30"><%= itemDescription %></td>
<td align="center" height="30"><%= getItemStatus(rowCrossHire("STATUS")) %></td>
<td align="center" height="30"><%= rowCrossHire("NLCODE") %></td>
<td align="center" height="30"><%= rowCrossHire("QTY") %></td>
<td align="center" height="30"><%= rowCrossHire("QTYRETD") %></td>
<td align="center" height="30"><%= formatcurrency(rowCrossHire("RATE#1"), 2) %></td>
<td align="center" height="30"><%= need to add "QTY" * "RATE#1" here %></td>
</tr>
<%
rowCrossHire.movenext
loop
end if
%>
<tr class="contract">
<th colspan="11"> </th>
</tr>
</table>
答案 0 :(得分:0)
您应该可以选择“QTY”*“RATE#1”作为SQL语句中的列,使用“AS columnName”将其别名,然后在输出中引用columnName。
在SQL中,使用
QTY * RATE#1 as TotalColumn
其中TotalColumn是您要在ASP代码中使用的值。