【发布时间】:2018-09-30 05:24:25
【问题描述】:
感谢大家的帮助和耐心,因为我通过将大型 Excel/vba 系统转换为 Access 来继续学习。
我有以下疑问:
SELECT AccountWeeklyBalances.AccountNumber,
AccountWeeklyBalances.AccountBalance,
AccountWeeklyBalances.AccountDate,
AccountMaster.AccountName,
AccountCurrentModel.Model,
ModelDetailAllHistory.Risk
FROM ((AccountWeeklyBalances
INNER JOIN AccountMaster
ON AccountMaster.[AccountNumber] = AccountWeeklyBalances.AccountNumber)
INNER JOIN AccountCurrentModel
ON AccountWeeklyBalances.AccountNumber=AccountCurrentModel.AccountNumber)
INNER JOIN ModelDetailAllHistory
ON AccountCurrentModel.Model=ModelDetailAllHistory.ModelName
WHERE AccountWeeklyBalances.AccountDate=[MatchDate]
;
这可行,但我想按模型分组。我尝试添加
GROUP BY AccountCurrentModel.Model
和
GROUP BY ModelDetailAllHistory.ModelName
在 WHERE 子句之后,但都给我一个错误:
Tried to execute a query that does not include the specified expression
'AccountNumber' as part of an aggregate function.
我在这里阅读了其他几篇文章,但无法弄清楚我做错了什么。
【问题讨论】:
-
错误信息似乎很清楚。你没有聚合,因此你不能分组。不过,您可以申请 Order By。
标签: sql ms-access select group-by ms-access-2010