我有一个查询,我一直在尝试改进以允许用户研究逐年比较信息。该查询工作正常,但我还没有弄清楚如何解决的数字分组问题。查询提示用户输入开始年份和结束年份,然后输入开始月份和结束月份。在 2-9 个月内一切正常,但是当使用 1、10、11 或 12 时,所有月份编号以 1 开头的字段都会出现。所以我要求今年和去年的第 1 个月和第 2 个月 我得到 1(ty) 1(ly) 2(ty) 2(ly) 10(ty) 10(ly) 11(ty) 11(ly) 12(ty) 12(ly)。如何只返回我请求的特定数字范围?
SELECT Month([EventLog]![Date]) & "/" & Year([EventLog]![Date]) AS [Date]
,EventLog.Type
,Count(EventLog.UserID) AS [Attendance Events]
,Year([EventLog]![Date]) AS [Year]
,Month([EventLog]![Date]) AS [Month]
FROM EventLog
WHERE (((EventLog.LogType) Like "Eve*"))
GROUP BY Month([EventLog]![Date]) & "/" & Year([EventLog]![Date])
,EventLog.Type
,Year([EventLog]![Date])
,Month([EventLog]![Date])
HAVING (((EventLog.Type) Like "Att*")
AND ((Year([EventLog]![Date])) Between [Enter Start Year:] And [Enter End Year:])
AND ((Month([EventLog]![Date])) Between [Enter Start Month:] And [Enter End Month:]))
ORDER BY Month([EventLog]![Date]);