1

我正在尝试进行计算并在 select 语句中填充一个字段。它看起来像这样:

    CREATE VIEW SALES_REPORT AS(
SELECT 
INVOICENO,
INVOICEDATE,
CLIENTID,
CONTACT,
INVOICEJOBNO,
ADDCHARGES,
CHARGESINFO,
EMPLOYEEID,
USUALPAY,
VAT,
SUBTOTAL (SELECT(USUALPAY * COUNT(*) AS SUBTOTAL FROM SALES_REPORT)),
TOTAL = (SUBTOTAL * VAT)
FROM SALES_REPORT_JOINS_CONFIG
GROUP BY INVOICENO ORDER BY INVOICEDATE DESC);

任何帮助都会很棒,谢谢!

4

1 回答 1

0
TOTAL = (SUBTOTAL * VAT)

应该是

(SUBTOTAL * VAT) AS TOTAL

现在它将返回相等比较的布尔真/假结果。您没有将乘法结果分配给“总计”字段 - 您正在将总计的任何值与乘法结果进行比较。

这是一个明确的语法错误:

SUBTOTAL (SELECT(USUALPAY * COUNT(*) AS SUBTOTAL FROM SALES_REPORT)),
于 2012-12-04T20:44:32.063 回答