这是我目前的桌子。
员工将有多个订单日期和发货日期。我想得到的是每个员工 Diff 总和的平均值。
一直在努力实现这一目标。
这是我到目前为止所做的。
USE Northwind
SELECT
e.EmployeeID,
e.LastName,
o.OrderDate,
o.ShippedDate,
DATEDIFF(DAY, o.OrderDate, o.ShippedDate) as Diff
FROM
Employees as e
JOIN Orders as o ON e.EmployeeID = o.EmployeeID