I have the following table with the test data set:
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`desc` varchar(20) DEFAULT NULL,
`amount` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8
insert into `test` (`id`, `desc`, `amount`) values('5',NULL,'847.3');
insert into `test` (`id`, `desc`, `amount`) values('6',NULL,'-847');
insert into `test` (`id`, `desc`, `amount`) values('7',NULL,'847.3');
insert into `test` (`id`, `desc`, `amount`) values('8',NULL,'-847');
insert into `test` (`id`, `desc`, `amount`) values('9',NULL,'847.4');
So the table looks like:
Now my problem is that when I use:
SELECT SUM(amount) FROM test;
I get the following results 847.9999999999999
instead of the expected 848
.
Any ideas why I dont get the decimals rounded?
Update:
I am have tested this on MySQL Server: 5.5.17
(windows) and MySQL Server: 5.5.20
Centos