我无法将每日数据(已汇总到月度数据)与月度数据相关联。我在Excel中有一个财务数据库,有两个表:
支出 - 购买时所有带有类别和日期(日/月/年)的购买
收入 - 按日期(月/年)的月收入
我有一个查询,它将每日支出汇总并按月分组:
SELECT Format(Outlays.period,"mmm-yy") AS Period, Sum(Outlays.Value) AS [Living Cost]
FROM Outlays
GROUP BY Format(Outlays.period,"mmm-yy"), Outlays.[Living Cost]
HAVING (((Outlays.[Living Cost])=True));
我遇到麻烦的地方是将收入数据加入此查询:
SELECT Format(Outlays.period,"mmm-yy") AS Period, Sum(Outlays.Value) AS [Living Cost]
FROM Outlays
JOIN Income ON Outlays.period = Income.Period
GROUP BY Format(Outlays.period,"mmm-yy"), Outlays.[Living Cost]
HAVING (((Outlays.[Living Cost])=True));
此查询返回“FROM子句中的语法错误”。
非常感谢有关正确语法的任何想法。
答案 0 :(得分:1)
在MS Access SQL中,您需要显式声明JOIN
的类型,而不是将其一般地保留为JOIN
。而在其他RDMS中,JOIN
默认为INNER JOIN
,在MS Access中您必须声明它。
FROM Outlays INNER JOIN Income ON Outlays.period = Income.Period
对于多个连接,必须将表/查询配对括在括号中:
FROM ((Outlays
INNER JOIN Income ON Outlays.period = Income.Period)
INNER JOIN OtherTable ON Outlays.id = OtherTable.id)
INNER JOIN AnotherTable ON Outlays.id = AnotherTable.id