gpt4 book ai didi

sql - 关于多个月份日期的快速 SQL 问题

转载 作者:行者123 更新时间:2023-12-04 18:23:51 27 4
gpt4 key购买 nike

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com