MS Access在开关中使用嵌套选择进行查询

时间:2019-02-08 14:14:22

标签: sql ms-access

我在我的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"))

1 个答案:

答案 0 :(得分:-1)

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

您在tblTaxiInvoices.TaxiInvDateClosed中使用WHERE,但是tblTaxiInvoices中没有FROM