我有一个查询可以完美地提取数据,但有一个例外,我希望数据总和在周年纪念日重新开始。我目前的查询是;
"qry_Vac2"
UserID Category Gain Used Left
查询 SQL;
SELECT
SchedulingLog.UserID,
SchedulingLog.Category,
Sum(IIf([CatDetail] Like 'Ann*',[Value],0))
AS Gain, Sum(IIf([CatDetail] Like '*Used*',[Value],0))+Sum(IIf([CatDetail] Like 'Adj*',[Value],0))
AS Used, [Gain]+[Used] AS [Left]
FROM
SchedulingLog
GROUP BY SchedulingLog.UserID, SchedulingLog.Category
HAVING (((SchedulingLog.Category) Like "Vac*"));
我对修改周年纪念活动后重置总和的想法;
SELECT Roster.UserID, Roster.[WM DOH], Roster.Schedule, Month([WM DOH]) & "/" & Day([WM DOH]) & "/" & Year(Date()) AS [Anniversary Date], SchedulingLog.Category, Sum(IIf([CatDetail] Like 'Ann*',[Value],0)) AS Gain, Sum(IIf([CatDetail] Like '*Used*',[Value],0))+Sum(IIf([CatDetail] Like 'Adj*',[Value],0)) AS Used, [Gain]+[Used] AS [Left]
FROM SchedulingLog INNER JOIN Roster ON SchedulingLog.UserID = Roster.UserID
WHERE (((SchedulingLog.EventDate)>[Anniversary Date]))
GROUP BY Roster.UserID, Roster.[WM DOH], Roster.Schedule, Month([WM DOH]) & "/" & Day([WM DOH]) & "/" & Year(Date()), SchedulingLog.Category;
修改后的查询不返回任何数据。想法?