Bug #61867 | SUM and ROUND unexpected behaviour | ||
---|---|---|---|
Submitted: | 14 Jul 2011 14:35 | Modified: | 14 Jul 2011 17:47 |
Reporter: | Jan Vernieuwe | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: General | Severity: | S3 (Non-critical) |
Version: | 5.1.55 | OS: | FreeBSD |
Assigned to: | CPU Architecture: | Any | |
Tags: | ROUND SUM |
[14 Jul 2011 14:35]
Jan Vernieuwe
[14 Jul 2011 15:06]
MySQL Verification Team
Could you please read the Manual about float: http://dev.mysql.com/doc/refman/5.1/en/problems-with-float.html Thanks.
[14 Jul 2011 16:25]
Jan Vernieuwe
okay, i found my workaround then, but it seems just weird to me that a pre-rounded float still causes the expected issues (the result was exactly 3.935). But i guess thats the internal handling then. workaround: mysql> SELECT ROUND(SUM(CAST(quantity*amount*vat AS CHAR)),2) FROM invoice_item WHERE invoiceid = 8; +-------------------------------------------------+ | ROUND(SUM(CAST(quantity*amount*vat AS CHAR)),2) | +-------------------------------------------------+ | 4.94 | +-------------------------------------------------+ 1 row in set (0.00 sec)
[14 Jul 2011 17:47]
Sveta Smirnova
Thank you for the feedback. Closing as "Not a Bug"