I\'m getting this error
msg 8115, level 16, state 2, line 18
Arithmetic overflow error converting expression to data type int.
Change SUM(billableDuration) AS NumSecondsDelivered to
sum(cast(billableDuration as bigint))
or
sum(cast(billableDuration as numeric(12, 0))) according to your need.
The resultant type of of Sum expression is the same as the data type used. It throws error at time of overflow. So casting the column to larger capacity data type and then using Sum operation works fine.