访问查询无法找到时差

时间:2013-11-08 10:24:33

标签: sql ms-access

我正在尝试在Access 2000 db中执行以下查询,但我总是在Diff字段中获得#ERROR。请帮我解决。

PARAMETERS [Enter Date] DateTime;
SELECT sub.Emp_ID, sub.Name, Dept, sub.Day, sub.Attending, sub.Leaving, sub.Leaving -         sub.Attending AS Diff
FROM [SELECT
        M.EmpID AS Emp_ID,M.Name,M.Dept,
IIf (IsNull(H.EventDate), "NP", H.EventDate) AS [Day],
        MIN(H.EventTime) AS Attending,
        MAX(H.EventTime) AS Leaving
    FROM
        Member AS M
        LEFT JOIN History AS H
        ON
            (M.UserID = H.EventUserID 
        AND Format([EventDate], "dd/mm/yyyy") = [Enter Date])
    WHERE
        M.EmpID NOT IN (select EmpID from exceptionList)
    GROUP BY
        M.EmpID, M.Name, M.Department,EventDate
]. AS sub
ORDER BY sub.Emp_ID;

1 个答案:

答案 0 :(得分:1)

尝试替换

   ON
             (M.UserID = H.EventUserID 
         AND Format([EventDate], "dd/mm/yyyy") = [Enter Date])
     WHERE

  ON
            ((M.UserID = H.EventUserID) 
        AND ([EventDate]= [Enter Date]))
    WHERE