我越來越與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)
謝謝
我認爲這可能是我見過 – GGio
它應該是tbl_payments.tax或tbl_quotesItems.tax最醜陋的查詢? – Alepac
@GGio那好些? – Kermit