我使用以下简单查询,执行时间超过一分钟。 有人会帮助我吗
SELECT qryCredit_Points.Employee_ID, qryCredit_Points.First_Name,
qryCredit_Points.Last_Name, Sum(qryCredit_Points.TotalCredit) AS
SumOfTotalCredit
FROM (
SELECT emp.*,
(SELECT top 1 a.attend_date
FROM Attendance AS a
WHERE a.ID_Employee=at.ID_Employee and a.attend_date > at.attend_date
order by a.attend_date asc )
AS NextDate,
IIf(IsNull(NextDate),Now(),Nextdate) AS next123,
Next123-at.attend_date AS difference, at.attend_date,
IIf(at.attend_date+90<Next123,1,0) AS Day90Credit,
IIf(at.attend_date+90<Next123,at.attend_date+90,at.attend_date+365) AS CreditDate,
IIf((Day90Credit=0 And CreditDate<Now()) Or Day90Credit=1,1,0) AS TotalCredit
FROM attendance AS [at],
Employees AS emp WHERE (((emp.Employee_ID)=[at].[ID_Employee]))
) AS qryCredit_Points
GROUP BY qryCredit_Points.Employee_ID, qryCredit_Points.First_Name,
qryCredit_Points.Last_Name;;