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:
Addition to HABO's and Rafi's answers.
For my case, I had to cast the value of the DATEDIFF to a bigint because my value grew too large and caused an arithmetic overflow error.
CAST(DATEADD( ms,AVG(CAST(DATEDIFF( ms, '00:00:00', ISNULL(e.Duration, '00:00:00')) as bigint)), '00:00:00' ) as TIME) as 'avg_time'