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:
Operand data type time is invalid for avg operator.
Duration is type time(4) such as:
Duration
-------------
00:00:10.0000
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 ).