Page 1 of 1

SUM of integer field becomes FLOAT bug?

Posted: Wed 07 Dec 2011 13:32
by m227
Dear sirs,

When I run query from MySQL Query Browser:

Code: Select all

SELECT 1, 1+1, SUM(1), SUM(1)*1.0
I get three results of integer and one (last) float. It is easy to notice when decimal separator and zero is after integer part.

When I put this query to TMyQuery and in Fields Editor select Add all fields, last two are floating point.

The same problem I have when I have such query:

Code: Select all

SELECT SUM(L1) FROM Table1;
WHERE L1 is of type INT(10) UNSIGNED. The result is float.
Is it possible to have SUM function of integer field to be integer?

Posted: Wed 07 Dec 2011 15:35
by AndreyZ
Hello,

Please take a look at the following article: http://dev.mysql.com/doc/refman/5.1/en/ ... tions.html . Here is a quotation from it:
For numeric arguments, the variance and standard deviation functions return a DOUBLE value. The SUM() and AVG() functions return a DECIMAL value for exact-value arguments (integer or DECIMAL), and a DOUBLE value for approximate-value arguments (FLOAT or DOUBLE).
MySQL server returns the DECIMAL type for columns received using the SUM function, that's why MyDAC maps them as TFloatField.