All Forums UDA
Ashok Pentapati 20 posts Joined 07/11
18 Jul 2011
Numeric Overflow While Sum

Hi All,

I tried to to do sum for a column where I am getting numeric overflow error.

Eg:
----
Sel
Sum(Col1) from Tab1 group by1 col2;

Where Col1 is an integer.

I tried to caste it as

Sel
Cast(Sum(Col1) as decimal(38,0))
from tab1 group by col2;

But I am still facing the error.Can someone help me out?

Thanks,
Ashok.

Jimm 298 posts Joined 09/07
18 Jul 2011

You are still adding it up as an integer and then casting the sum.You need to cast the individual values and the add them up.

So:

Sel
sum(Cast(Col1 as decimal(38,0)))
from tab1 group by col2;

Ashok Pentapati 20 posts Joined 07/11
19 Jul 2011

Thank you very much Jimm.It worked.

You must sign in to leave a comment.