SELECT DISTINCT MonthName(Month([Date])) AS [Month], tblSupportCalls.System, Count(tblSupportCalls.System) AS [Total for System], Year([Date]) AS [Year]
FROM tblSupportCalls
WHERE (((tblSupportCalls.Date) Between Now() And Now()-7) AND ((tblSupportCalls.System) In ('Career Campus','E-PEEP')) AND ((tblSupportCalls.StartTime) Is Not Null) AND ((Hour([StartTime]))>=7))
GROUP BY tblSupportCalls.System, tblSupportCalls.Date;

每当我输入它会给我几个月的时间,例如:
July
July
July

我只想说 7 月 1 次,我不明白为什么每个领域都会在不同的日子里重复。我只想说:

月 |系统 |总系统 |年

我在看的是
> MONTH | System | Total Systems | Year
> July      CC           2         2010
> July      CC           7         2010
> July      CC           9         2010
> July      EE           1         2010
> July      EE           2         2010

需要是:
MONTH | System | Total Systems | Year
July      CC          18         2010
July      EE          03         2010

最佳答案

您想按年和月而不是 tblSupportCalls.Date 分组。

...
GROUP BY tblSupportCalls.System, Year([Date]), Month([Date]);

关于sql - 关于多月日期的快速 SQL 问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5160800/

10-12 17:25