填充select语句中的字段 - MySQL

时间:2012-12-04 20:41:38

标签: mysql sql phpmyadmin

我正在尝试进行计算并填充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);

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

1 个答案:

答案 0 :(得分:0)

TOTAL = (SUBTOTAL * VAT)

应该是

(SUBTOTAL * VAT) AS TOTAL

现在它将返回相等比较的布尔值true / false结果。您并未将乘法结果分配给“' total' field - 你要将总数中的任何值与乘法结果进行比较。

这是一个完整的语法错误:

SUBTOTAL (SELECT(USUALPAY * COUNT(*) AS SUBTOTAL FROM SALES_REPORT)),