请求帮助以下查询MS ACCESS的“NOT EXISTS”功能。以下是查询。数据仍然从VATExclusion表中获取,但它应该排除GRATE_Source表中可以在VATExclusion表中使用的所有GL.
VATExclusion中的排除参数是GL从GRT_Source表中排除,如果它们在VATExclusion基础上可用,VATExclusion.Branch + VATExclusion.GL在范围内+ VATExclusion.Base_No。
问题是:查询是从VATExlcution表中排除所有GL,除了有关perticualr分支标准的数据
SELECT GRT_Source.LV_ID, GRT_Source.GL_ACCT_ID, GRT_Source.TRAN_CCY_CD, GRT_Source.FUNC_CCY_CD, GRT_Source.LCL_LV_ID, GRT_Source.LCL_GL_ACCT_1, GRT_Source.LV_SUB_DIVN_ID, GRT_Source.ENTRPS_PROD_ID, GRT_Source.GOC, GRT_Source.CPRT_GOC, GRT_Source.CUST_ID, GRT_Source.CUST_ID_TYP_CD, GRT_Source.FYR, GRT_Source.ACTG_PRD_NO, GRT_Source.LCL_CUST_ID, GRT_Source.LCL_PROD_ID, GRT_Source.SUB_GL_FEED_ID, GRT_Source.FRS_BSUNIT_ID, GRT_Source.FDL_ACCT_ID, GRT_Source.FRS_OPER_UNIT_ID, GRT_Source.SRC_SYS_ARRG_ID, GRT_Source.TRAN_CCY_MTD_BAL_AMT, GRT_Source.FUNC_CCY_MTD_BAL_AMT, GRT_Source.RPRT_CCY_MTD_BAL_AMT, Domicile.DO
FROM GRT_Source LEFT JOIN Domicile ON GRT_Source.LCL_CUST_ID=Domicile.LCL_CUST_ID
WHERE Left(GRT_Source.LCL_GL_ACCT_1,1)="4" AND
Left(GRT_Source.SUB_GL_FEED_ID,3) Not Like "%ADJ%" And
Left(GRT_Source.SUB_GL_FEED_ID,3) Not Like "%FRM%" AND
NOT EXISTS(SELECT 1 from VATExclusion where GRT_Source.LCL_LV_ID=VATExclusion.Branch and GRT_Source.LCL_GL_ACCT_1 between VATExclusion.START_Flexcube_GL and VATExclusion.END_Flexcube_GL AND GRT_Source.LCL_CUST_ID between VATExclusion.Base_No and VATExclusion.Base_No_End);