Hi, I'm hoping someone here can help me. I'm running into an issue when attempting to divide 2 values to make a percentage, I am converting the value into a decimal to make it work which it does most of the time, but on some days I get the error

"Arithmetic overflow error converting expression to data type int."

`FORMAT((Coalesce(Sum(Case When StatusKey In ('on vacation','gone home','out of the office', 'acdagentnotanswering', 'invalid status') Then Convert(Decimal(7,2),StateDuration) End)/NULLIF(Sum(Case When StatusKey is not null Then Convert(Decimal(7,2),Stateduration) End),0),0)),'P') as [Inactive%]`

If I remove the decimal conversion then I return 0% for every row.

`FORMAT((Coalesce(Sum(Case When StatusKey In ('on vacation','gone home','out of the office', 'acdagentnotanswering', 'invalid status') Then StateDuration End)/NULLIF(Sum(Case When StatusKey is not null Then Stateduration End),0),0)),'P') as [Inactive%]`

How can I return the correct percentage without getting the Arithmetic overflow error?

An example output of the table is below. Stateduration is an INT

Thanks in advance

David