Bug #42691 ROUND function not working properly in the complex queries
Submitted: 9 Feb 2009 12:12 Modified: 9 Feb 2009 13:04
Reporter: Maxim Andruhovich Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.31 OS:Windows (XP)
Assigned to: CPU Architecture:Any
Tags: complex queries, round

[9 Feb 2009 12:12] Maxim Andruhovich
Description:
It`s not a duplicate of #4499 It`s another one.

Now is everything fine using ROUND() in simple queries like SELECT ROUND(6.655, 2);
Everything fine the result is 6.66

But, using ROUND in the SELECT statement you got wrong result, like 6.65

How to repeat:
create table and data:

DROP TABLE IF EXISTS `roundtest`;
CREATE TABLE IF NOT EXISTS `roundtest` (
  `rd_id` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
  `rd_sum` double(251,4) unsigned NOT NULL,
  PRIMARY KEY (`rd_id`),
  KEY `rd_sum` (`rd_sum`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3;

INSERT INTO `roundtest` (`rd_id`, `rd_sum`) VALUES(1, 3.2820);
INSERT INTO `roundtest` (`rd_id`, `rd_sum`) VALUES(2, 3.3730);

run the query:
SELECT ROUND( SUM( rd_sum ) , 2 ) FROM roundtest;
[9 Feb 2009 12:38] Maxim Andruhovich
Not working properly in version 5.1.30 and 5.1.31
[9 Feb 2009 13:04] MySQL Verification Team
Thank you for the bug report. Duplicate of bug: http://bugs.mysql.com/bug.php?id=15936