MS 访问 在我的查询的开关中使用嵌套选择



我在 Switch 查询中使用嵌套的 Select,似乎找不到错误,希望有人能为我发现它。

SELECT tblTaxiInvoices.TaxiInvID, tblTaxiInvoices.TaxiInvNo, tblChitRegister.pkchitnumber, tblClientRegister.fkTMS_Number, tblFunds.fund, tblFundCentres.fundcentre, tblCostCentres.costcentre, tblGLAccounts.glaccount, tblClientRegister.IO_id,     tblClientRegister.WBS_id, tblClientRegister.commit_code, tblChitRegister.faceamount, tblChitRegister.adminfee
, [faceamount]*0.884956 AS facenetofGST
,Switch
 (
 (Select HSTFactor From tblProvincialTaxes where tblTaxiInvoices.TaxiInvDateClosed >= CreatedDate and PID = 6 and active = 'yes') as TestfacenetofGST, ( [faceamount]* TestfacenetofGST )  ,
 (Select HSTFactor From tblProvincialTaxes where tblTaxiInvoices.TaxiInvDateClosed <= CreatedDate and PID = 6 and active = 'No') as TestfacenetofGST, ( [faceamount]* TestfacenetofGST ),0
 ) as xxx
, [facenetofGST]+[adminfee] AS TtlToClient
, tblTaxiCos.taxico, tblTaxiCos.prov, tblTaxiInvoices.Closed, tblTaxiInvoices.TaxiInvDateClosed
, (Select HSTFactor From tblProvincialTaxes where tblTaxiInvoices.TaxiInvDateClosed > CreatedDate and PID = 6 and active = 'yes') as test
FROM (tblTaxiCos INNER JOIN tblTaxiInvoices ON tblTaxiCos.pktaxico_id = tblTaxiInvoices.TaxiCoID) INNER JOIN (tblGLAccounts INNER JOIN (tblFunds INNER JOIN (tblFundCentres INNER JOIN (tblCostCentres INNER JOIN (tblClientRegister INNER JOIN     tblChitRegister ON tblClientRegister.pkclient_id = tblChitRegister.fkclient_id) ON tblCostCentres.pkcostcentre_id = tblClientRegister.fkcostcentre_id) ON tblFundCentres.pkfundcentre_id = tblClientRegister.fkfundcentre_id) ON tblFunds.pkfund    _id =     tblClientRegister.fkfund_id) ON tblGLAccounts.pkglaccount_id = tblClientRegister.fkglaccount_id) ON tblTaxiInvoices.TaxiInvID = tblChitRegister.taxiinv_ID
WHERE (((tblTaxiCos.prov)="ON"))

可能有多个错误,但这里有一个:

您在WHERE中使用tblTaxiInvoices.TaxiInvDateClosed tblTaxiInvoices但不在您的FROM中。

最新更新