如果我不使用groupby [Service Order Labor].EmployeeID
条款
我想要实现的是列出分配给员工的所有工作单,因此如果一个员工有多个记录,则应将其写为一组
SELECT [Service Order Labor].WorkorderLaborID, [Service Order Labor].WorkorderID, Customers.ID AS CustomerID, Customers.SiteName AS Customer, [Service Orders].ProblemDescription, Employees.[EmployeeID#] AS EmployeeID, Employees.EmployeeName, [Service Order Labor].SERVICED AS StartDate, [Service Orders].DateFinished AS CompletedDate, [Service Order Labor].DISPATCH, [Service Types].Type, [Service Orders].[PRIORITY#], [Service Orders].COMPLETE, [Service Order Labor].ACTIVE
FROM (((Customers INNER JOIN [Service Orders] ON Customers.ID = [Service Orders].ID) INNER JOIN [Service Order Labor] ON [Service Orders].WorkorderID = [Service Order Labor].WorkorderID) INNER JOIN Employees ON [Service Order Labor].EmployeeID = Employees.[EmployeeID#]) INNER JOIN [Service Types] ON [Service Orders].Type = [Service Types].TypeID
ORDER BY [Service Order Labor].SERVICED, [Service Order Labor].WorkorderID group by [Service Order Labor].EmployeeID;
错误
答案 0 :(得分:1)
你可以退休一些“(”尝试:
SELECT [Service ORDER Labor].WorkorderLaborID,
[Service ORDER Labor].WorkorderID,
Customers.ID AS CustomerID,
Customers.SiteName AS Customer,
[Service Orders].ProblemDescription,
Employees.[EmployeeID#] AS EmployeeID,
Employees.EmployeeName,
[Service ORDER Labor].SERVICED AS StartDate,
[Service Orders].DateFinished AS CompletedDate,
[Service ORDER Labor].DISPATCH,
[Service Types].Type,
[Service Orders].[PRIORITY#],
[Service Orders].COMPLETE,
[Service ORDER Labor].ACTIVE
FROM Customers
INNER JOIN [Service Orders] ON (Customers.ID = [Service Orders].ID)
INNER JOIN [Service ORDER Labor] ON ([Service Orders].WorkorderID = [Service ORDER Labor].WorkorderID)
INNER JOIN Employees ON ([Service ORDER Labor].EmployeeID = Employees.[EmployeeID#])
INNER JOIN [Service Types] ON ([Service Orders].Type = [Service Types].TypeID)
ORDER BY
[Service ORDER Labor].SERVICED,
[Service ORDER Labor].WorkorderID
group by
[Service ORDER Labor].EmployeeID;