Monday, March 12, 2012

getting overflow error doing avg(size)

Hello Everyone,
I am trying to calculate the average of a column with integer data type.
The table has millions of rows and I get overflow error message when I run
the following statement:
SELECT avg(col_name) FROM tbl_name
Not sure how to use CAST or CONVERT function with Average function.
Thanks for all the help!
Happy new year everyone.
--
MitraOn Tue, 3 Jan 2006 15:49:02 -0800, mitra wrote:

>Hello Everyone,
>I am trying to calculate the average of a column with integer data type.
>The table has millions of rows and I get overflow error message when I run
>the following statement:
>SELECT avg(col_name) FROM tbl_name
>Not sure how to use CAST or CONVERT function with Average function.
Hi Mitra,
Try
SELECT AVG(CAST(col_name AS bigint))
FROM tbl_name
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

No comments:

Post a Comment