MySQL Forums
Forum List  »  Newbie

Re: Sum converts integer to string ?
Posted by: Rick James
Date: April 12, 2014 02:31PM

I believe that any sized INT (even TINYINT) SUMs into BIGINT.
And FLOAT SUMs into DOUBLE.

It smells like ODBC is the real villain.

INT is always 4 bytes; the (6) and (20) mean nothing to mysql unless you also say ZEROFILL. BIGINT is always 8 bytes.

I agree with PB -- formatting should be done in the app. That said, you could use the FORMAT() function to have MySQL add commas as thousands separators. (However justification is your concern.)

mysql> SELECT 1234567 AS just_a_number, FORMAT(1234567, 0);
+---------------+--------------------+
| just_a_number | FORMAT(1234567, 0) |
+---------------+--------------------+
|       1234567 | 1,234,567          |
+---------------+--------------------+

Options: ReplyQuote


Subject
Written By
Posted
Re: Sum converts integer to string ?
April 12, 2014 02:31PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.