All Forums Database
TERA_DW 2 posts Joined 11/10
12 Nov 2010
Numeric overflow error for AVG function

hello,
we all knew that we may get numeric overflow during count, sum etc... but I see that with MIN, MAX, and AVG functions too... All I am doing is just picking one of the existing values...

I also tried to CASTing to DECIMAL(38,0) and no luck in there...

After doing the above casting, MIN and MAX went well, but not AVG. AVG is anyways between MIN and MAX values and i am surprised that AVG didn't work..

any thoughts please??

TERA_DW 2 posts Joined 11/10
12 Nov 2010

OKIE, to compute average, it should first compute the SUM internally and that's where the issue coming I think... so, I think, the sum is going beyond the container...

spriggy 2 posts Joined 05/13
06 May 2013

To get rid of the error use the following format and you should no longer get an error:
AVG( CAST( column_name as DECIMAL(16,0)))

You must sign in to leave a comment.