All Forums Database
larun1616 29 posts Joined 09/14
28 Oct 2014
AVG() FUNCTION RETURNING DIFFERENT VALUES FOR SAME INPUT

HI
   I am using the average function to find the average of column having many rows. Each time i execute the query i get different result sets. The change is very small in precision. Ex. 16.12345678 and 16.12345679. Why do i see this change? Am i making some mistake here or is it something with Teradata? Please help.
 
Regards
Arun

Tags:
dnoeth 4628 posts Joined 11/04
28 Oct 2014

Hi Arun,
the resulting datatype of an AVG is a FLOAT.
What's the datatype of the base column?
You can rewrite an any AVG(column) using SUM(column) / COUNT(column) which will use the original type (but might have to cast it to a higher number of digits).
 

Dieter

larun1616 29 posts Joined 09/14
28 Oct 2014

Thanks. The data type of base column is DECIMAL(38,8) and the resulting data type is also same.

ravimans 54 posts Joined 02/14
29 Oct 2014

Hi Arun,
If you are still facing the issue, can you share the query?

You must sign in to leave a comment.