views:

84

answers:

1

I am in the process of upgrading a few in-house applications from ADS7.1 to 8.1. I was told a while back that there are changes in return values of the avg() function as well as some division calculations, but I cannot find any documentation on these changes. Does anyone know what I'm talking about or have a link that explains the details?

Thanks!

+2  A: 

The "Effects of Upgrading to Version 8.1" topic in the help file has a small paragraph about the change, but doesn't go into any details.

Basically, as of version 8.1 Advantage now adheres to the SQL standard with regards to integer division. Integer division expressions have the fractional portion truncated, where in the past they would result in a floating point result.

To address this change, you may have to cast certain expressions if you still want them to result in a floating point data type. For example:

This:

select int1 / int2 from mytable;

Would need to change to:

select cast( int1 as sql_float ) / int2 from mytable;
Jeremy Mullin
Thank you Jeremy. Very Informative. Does this affect the result of the avg function as well? Any other functions that are affected by this "new math"?
KOGI
avg behaves the same as it did in v8.1. In 8.1 it returns the same data type as the expression it is called on. For example, if you avg(intField) you will get an integer. If you avg( double_field ) you will get a double, etc. That behavior is the same.
Jeremy Mullin