查询中的过滤器

时间:2010-06-29 19:22:48

标签: ms-access

我有4个总查询和3个单独的查询,这些查询从预算表和帐号表中获取预算信息,这些信息将进入4查询。对于名为bud11的查询,我有一些不在其他2个查询中的帐户(bud10和actvproj)。当我自己运行bud11时,我需要的所有帐户都显示出来。但是当我运行具有Bud11,bud10和actvproj数据的第四个查询(CCQUERY)时,有一些帐户丢失.....以下是每个查询的4个sql视图。

BUD11QUERY

SELECT BUDGET.FISCAL_YEAR, BUDGET.BUDGET_NBR, BUDGET.ACCT_UNIT, BUDGET.ACCOUNT, ZBASED.ACCOUNT_DESC, BUDGET.DB_AMOUNT_01+BUDGET.DB_AMOUNT_02+BUDGET.DB_AMOUNT_03+BUDGET.DB_AMOUNT_04+BUDGET.DB_AMOUNT_05+BUDGET.DB_AMOUNT_06+BUDGET.DB_AMOUNT_07+BUDGET.DB_AMOUNT_08+BUDGET.DB_AMOUNT_09+BUDGET.DB_AMOUNT_10+BUDGET.DB_AMOUNT_11+BUDGET.DB_AMOUNT_12+BUDGET.CR_AMOUNT_01+BUDGET.CR_AMOUNT_02+BUDGET.CR_AMOUNT_03+BUDGET.CR_AMOUNT_04+BUDGET.CR_AMOUNT_05+BUDGET.CR_AMOUNT_06+BUDGET.CR_AMOUNT_07+BUDGET.CR_AMOUNT_08+BUDGET.CR_AMOUNT_09+BUDGET.CR_AMOUNT_10+BUDGET.CR_AMOUNT_11+BUDGET.CR_AMOUNT_12 AS Bud11
FROM BUDGET INNER JOIN ZBASED ON BUDGET.ACCOUNT = ZBASED.ACCOUNT
WHERE (((BUDGET.FISCAL_YEAR)=2011) AND ((BUDGET.BUDGET_NBR)=2) AND ((ZBASED.ACCT_UNIT)=[BUDGET].[ACCT_UNIT] And (ZBASED.ACCT_UNIT)=[Cost Center]))
ORDER BY ZBASED.ACCOUNT; 

BUD10QUERY

SELECT BUDGET.FISCAL_YEAR, BUDGET.BUDGET_NBR, BUDGET.ACCT_UNIT, BUDGET.ACCOUNT, ZBASED.ACCOUNT_DESC, BUDGET.DB_AMOUNT_01+BUDGET.DB_AMOUNT_02+BUDGET.DB_AMOUNT_03+BUDGET.DB_AMOUNT_04+BUDGET.DB_AMOUNT_05+BUDGET.DB_AMOUNT_06+BUDGET.DB_AMOUNT_07+BUDGET.DB_AMOUNT_08+BUDGET.DB_AMOUNT_09+BUDGET.DB_AMOUNT_10+BUDGET.DB_AMOUNT_11+BUDGET.DB_AMOUNT_12+BUDGET.CR_AMOUNT_01+BUDGET.CR_AMOUNT_02+BUDGET.CR_AMOUNT_03+BUDGET.CR_AMOUNT_04+BUDGET.CR_AMOUNT_05+BUDGET.CR_AMOUNT_06+BUDGET.CR_AMOUNT_07+BUDGET.CR_AMOUNT_08+BUDGET.CR_AMOUNT_09+BUDGET.CR_AMOUNT_10+BUDGET.CR_AMOUNT_11+BUDGET.CR_AMOUNT_12 AS Bud10
FROM BUDGET INNER JOIN ZBASED ON BUDGET.ACCOUNT=ZBASED.ACCOUNT
WHERE (((BUDGET.FISCAL_YEAR)=2010) AND ((BUDGET.BUDGET_NBR)=1) AND ((ZBASED.ACCT_UNIT)=BUDGET.ACCT_UNIT) And ((ZBASED.ACCT_UNIT)=[Cost Center]))
ORDER BY ZBASED.ACCOUNT;

ACTvPROJ QUERY

SELECT BUDGET.FISCAL_YEAR, BUDGET.BUDGET_NBR, BUDGET.ACCT_UNIT, BUDGET.ACCOUNT, ZBASED.ACCOUNT_DESC, BUDGET.DB_AMOUNT_01+BUDGET.DB_AMOUNT_02+BUDGET.DB_AMOUNT_03+BUDGET.DB_AMOUNT_04+BUDGET.DB_AMOUNT_05+BUDGET.DB_AMOUNT_06+BUDGET.DB_AMOUNT_07+BUDGET.DB_AMOUNT_08+BUDGET.DB_AMOUNT_09+BUDGET.DB_AMOUNT_10+BUDGET.DB_AMOUNT_11+BUDGET.DB_AMOUNT_12+BUDGET.CR_AMOUNT_01+BUDGET.CR_AMOUNT_02+BUDGET.CR_AMOUNT_03+BUDGET.CR_AMOUNT_04+BUDGET.CR_AMOUNT_05+BUDGET.CR_AMOUNT_06+BUDGET.CR_AMOUNT_07+BUDGET.CR_AMOUNT_08+BUDGET.CR_AMOUNT_09+BUDGET.CR_AMOUNT_10+BUDGET.CR_AMOUNT_11+BUDGET.CR_AMOUNT_12 AS ActvProj10
FROM BUDGET INNER JOIN ZBASED ON BUDGET.ACCOUNT=ZBASED.ACCOUNT
WHERE (((BUDGET.FISCAL_YEAR)=2010) And ((BUDGET.BUDGET_NBR)=6) And ((ZBASED.ACCT_UNIT)=BUDGET.ACCT_UNIT And (ZBASED.ACCT_UNIT)=[Cost Center]))
ORDER BY ZBASED.ACCOUNT;

CCQUERY

SELECT ZBASED.ACCT_UNIT, CCtable.CenterName, ZBASED.ACCOUNT, ZBASED.ACCOUNT_DESC, qryBUD11.Bud11, qryBUD10.Bud10, qryACTvPROJ.ActvProj10
FROM CCtable, ((ZBASED INNER JOIN qryACTvPROJ ON ZBASED.ACCOUNT = qryACTvPROJ.ACCOUNT) INNER JOIN qryBUD11 ON ZBASED.ACCOUNT = qryBUD11.ACCOUNT) INNER JOIN qryBUD10 ON ZBASED.ACCOUNT = qryBUD10.ACCOUNT
WHERE (((ZBASED.ACCT_UNIT)=[Cost Center]) AND ((CCtable.CenterNo)=[Cost Center]))
ORDER BY ZBASED.ACCOUNT;

任何人都可以帮我弄清楚为什么CCQUERY会丢失一些帐户吗?

1 个答案:

答案 0 :(得分:1)

在最终查询中尝试LEFT JOINS而不是INNER JOINS。