Sql MS Access在我的查询开关中使用嵌套的select
我在交换机查询中使用嵌套的Select,似乎无法找到错误,希望有人能帮我发现Sql MS Access在我的查询开关中使用嵌套的select,sql,ms-access,Sql,Ms Access,我在交换机查询中使用嵌套的Select,似乎无法找到错误,希望有人能帮我发现 SELECT tblTaxiInvoices.TaxiInvID, tblTaxiInvoices.TaxiInvNo, tblChitRegister.pkchitnumber, tblClientRegister.fkTMS_Number, tblFunds.fund, tblFundCentres.fundcentre, tblCostCentres.costcentre, tblGLAccounts.glacc
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"))
可能有多个错误,但这里有一个:
您正在使用tblTaxiInvoices.TaxiInvDateClosed,但tblTaxiInvoices不在FROM中。请发布运行此查询时引发的错误。如果不解释您要检索的内容,以及所有相关表的示例日期和它们的预期输出,查询就没有多大意义。开关内部的语法错误。不能在其中一个表达式中使用TestfacenetofGST,然后在下一个表达式中引用该表达式。但是,在不知道您希望得到什么输出的情况下,我不知道我们能为您提供什么帮助。我重新发布了我已经编辑了所有内容以便于阅读。我还觉得您可以将查询减少到最低限度,只涉及一两个表,足以重现问题。如果查询中再抛出7个表,而这些表实际上并没有导致错误,那么这并没有帮助。因此,在Switch语句中,我试图根据发票日期从另一个表中检索税率。正如你在开关上方看到的,系数是硬编码的,我在表中有费率。