我正在用 MS Access SQL 编写一个查询,做一些数学运算。
SELECT
DISTINCT QParts.PartsNumber,
SWITCH(([dbo_ICILOC].[QTYONHAND] + [dbo_ICILOC].[QTYRENOCST] + [dbo_ICILOC].[QTYADNOCST] - [dbo_ICILOC].[QTYSHNOCST] - [dbo_ICILOC].[QTYCOMMIT]) IS NULL,
0,
([dbo_ICILOC].[QTYONHAND] + [dbo_ICILOC].[QTYRENOCST] + [dbo_ICILOC].[QTYADNOCST] - [dbo_ICILOC].[QTYSHNOCST] - [dbo_ICILOC].[QTYCOMMIT]) <= 0,
0, ([dbo_ICILOC].[QTYONHAND] + [dbo_ICILOC].[QTYRENOCST] + [dbo_ICILOC].[QTYADNOCST] - [dbo_ICILOC].[QTYSHNOCST] - [dbo_ICILOC].[QTYCOMMIT]) >= 0,
([dbo_ICILOC].[QTYONHAND] + [dbo_ICILOC].[QTYRENOCST] + [dbo_ICILOC].[QTYADNOCST] - [dbo_ICILOC].[QTYSHNOCST] - [dbo_ICILOC].[QTYCOMMIT])) AS avqty,
SWITCH(dbo_ICILOC.QTYONORDER IS NULL,
0,
dbo_ICILOC.QTYONORDER >= 0,
(([AESTUSA.QTYONORDER] + [dbo_ICILOC].[QTYONORDER]) + SUM(IIf(([dbo_ICILOC].[QTYONHAND] - [dbo_ICILOC].[QTYCOMMIT]) > 0,
0,
([dbo_ICILOC].[QTYONHAND] - [dbo_ICILOC].[QTYCOMMIT])))) AS qtyorder
FROM
QParts
LEFT JOIN
dbo_ICILOC ON
QParts.PartsNumber = dbo_ICILOC.ITEMNO
AND
dbo_ICILOC.LOCATION = "UBN"
LEFT JOIN
dbo_ICILOC AS AESTUSA ON
QParts.PartsNumber = AESTUSA.ITEMNO
AND
AESTUSA.LOCATION = "UBCUST";
但是这个查询给了我很多错误。我错过了什么?