我的having子句有问题,这是我遇到的错误:
中的未知tbl_quotes.tax
列having clause
和我的代码:
SELECT tbl_quotes.docnumber AS docNumber,
tbl_quotes.date AS date,
Sum(tbl_quotesitems.price) * ( ( tax + tax2 / 100 ) + 1 ) AS total,
( Sum(tbl_quotesitems.price) * ( ( tax + tax2 / 100 ) + 1 ) ) -
(SELECT Sum(tbl_payments.amount)
FROM tbl_payments
WHERE tbl_payments.quoteid = tbl_quotes.id
) AS amtOwing
FROM tbl_quotes
INNER JOIN tbl_quotesitems
ON tbl_quotesitems.quoteid = tbl_quotes.id
GROUP BY tbl_quotes.id
HAVING ( Sum(tbl_quotesitems.price) * ( ( ( tbl_quotes.tax + tbl_quotes.tax2 ) /
100 )
+
1 ) ) < (SELECT Sum(
tbl_payments.amount)
FROM tbl_payments
WHERE
tbl_payments.quoteid = tbl_quotes.id)
谢谢