我试图让每个插座在几分钟内获得平均接收时间。
我有两份订单和收货订单。
订单
OrderID OutletID OrderDate
1 1 2017-04-10 17:04:41.000
ReceivedOrders
ReceivingID OrderID ReceivingDate
1 1 2017-04-10 17:06:31.000
我已尝试过以下查询,但其重新计算为零作为平均接收时间
SQL查询
SELECT Outlets.OutletName , avg(datediff(MM, Orders.OrderDate, ReceivedOrders.ReceivingDate)) as Receive
FROM dbo.Orders INNER JOIN
dbo.Outlets ON dbo.Orders.OutletID = dbo.Outlets.OutletID INNER JOIN
dbo.ReceivedOrders ON dbo.Orders.OrderID = dbo.ReceivedOrders.OrderID
group by dbo.Outlets.OutletName
输出
OutletName Receive
Outlet1 0
答案 0 :(得分:1)
使用具有毫秒选项的datediff:
" and _new_technology_value eq '"+techid+"'";