0

您好我正在尝试以下操作:

代码用 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">&nbsp;</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&amp;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">&nbsp;</th>
    </tr>
</table>
4

1 回答 1

0

您应该能够在 SQL 语句中选择“QTY”*“RATE#1”作为列,使用“AS columnName”为其别名,然后在输出中引用 columnName。

在您的 SQL 中,使用

QTY * RATE#1 as TotalColumn

其中 TotalColumn 是您要在 ASP 代码中使用的值。

于 2013-11-01T15:07:23.970 回答