我有这些时间值(varchar):[hh:mm]
2:41 2:31 1:46 21:41 18:19 17:56 18:4 17:17 17:2 16:39 0:40 0:38 0:38 0:29 1:19 2:52 0:15 16:55 17:25 17:15 3:31 2:7 2:21 1:35 1:38 0:17 0:28 18:40 2:54 18:14 2:31 18:9 18:10 0:39 0:38 3:5 3:20 3:6 2:58 2:31 2:4 1:54 2:2 1:44 1:39 1:22 1:6 1:15 0:53 1:13 20:32 1:11 0:36 0:35 0:26 1:3 4:20 3:42 3:7 3:16 2:44 2:30 0:40 2:5 4:21 2:6 3:54 3:45 3:31 18:59 18:59 18:47 18:43 19:40 19:29 2:19 1:9 4:10 3:50 2:20 1:16 4:33 21:23 20:57 16:31 1:51 5:15 1:48 3:15 1:32 4:19 4:17 1:59 3:38 1:55 2:11 1:26
现在,当我在 excel 中做平均时,结果是:6:14
如果我在 sql 中执行此操作:(使用:This)
select
Month(OperationDate) [Month], count(distinct IdOrder) OrderQty,
avg(DATEPART(hh,TimeSpent)*60 + DATEPART(mi,TimeSpent)) % 24 as AvgHour,
avg(DATEPART(hh,TimeSpent)*60 + DATEPART(mi,TimeSpent)) / 24 as AvgMinute
from @tmp1 tmp1
inner join tblCheckList tcl on tmp1.IdCheckList = tcl.IdCheckList
where TimeSpent<>'0:0'
group by Month(OperationDate)
它返回平均值:10:15
为什么有区别?