Operand data type time is invalid for avg operator…?

后端 未结 4 1473
渐次进展
渐次进展 2020-12-11 16:16

How can I avg(time(4)) in the following query:

  select top 10 avg(e.Duration) from TimeTable e

I\'m getting the following error:

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 16:49

    You can use DateDiff( ms, '00:00:00', e.Duration ) to convert the time into an integer number of milliseconds. Use that for your aggregate, then convert the result back, e.g. Cast( DateAdd( ms, 1234, '00:00:00' ) as Time ).

提交回复
热议问题