Daniel Hutmacher shows how you can aggregate date and time data types in SQL Server:
Because the “Duration” column is a “time(3)” datatype, it doesn’t really aggregate into an average that easily.
Msg 8117, Level 16, State 1, Line 20 Operand data type time is invalid for avg operator.
This may seem a little odd, as time is really a continuum just like any integer or floating-point value, right?
Read on to see how to do this and a warning from Daniel about overflowing. This sort of aggregation is a lot easier to do in R, but you can still do it in T-SQL.