IIF总和查询错误-无法使用子查询

时间:2018-10-12 13:27:11

标签: ms-access ms-access-2013

我正在尝试使此查询正常工作,并抛出以下错误:无法在表达式中使用子查询...

SELECT qrySrcReq.MDC_Office,
Count(qrySrcReq.ReqNumKey) AS Ct_ReqNRs,
Count(IIf([3PL]="yes",0)) AS Ct_3PLReqNrs,
Count(IIf([3PL] Is Null,0)) AS Ct_OtherReqNrs,
Sum(IIf([3PL]="yes",[BO_Qty],0)) AS Sum_3PLBOs,
Sum(qrySrcReq.BO_Qty) AS BO_Qty,
IIf([qrySrcReq]![Priority] Like "04*","3PL","Tactical") AS Strategy
FROM qrySrcReq
WHERE (((qrySrcReq.Priority) Like "04*") AND ((qrySrcReq.[3PL Status])="C")) OR (((qrySrcReq.Priority) Is Not Null) AND ((qrySrcReq.[3PL Status]) Is Null Or (qrySrcReq.[3PL Status])=""))
GROUP BY qrySrcReq.MDC_Office,
IIf([qrySrcReq]![Priority] Like "04*","3PL","Tactical");

引发错误的行是: Sum(IIf([3PL] =“ yes”,[BO_Qty],0))作为Sum_3PLBOs

还有另一种方法可以使它正常工作吗?谢谢。

1 个答案:

答案 0 :(得分:1)

更改

Sum(qrySrcReq.BO_Qty) AS BO_Qty

Sum(qrySrcReq.BO_Qty) AS Sum_BO_Qty