The error in calculating the sum function of MySQL 4.0.18 for NT is found.

Source: Internet
Author: User

The error in calculating the sum function of MySQL 4.0.18 for NT is found.
Mysql> Create Table CH3 (ID char (32), V decimal (18, 2 ));
Query OK, 0 rows affected (0.12 Sec)

Mysql> insert into CH3 select * From vc2;
Query OK, 8192 rows affected (1.24 Sec)
Records: 8192 duplicates: 0 Warnings: 0

Mysql> select max (v) from CH3;
+ ------------- +
| Max (v) |
+ ------------- +
| 1, 99999999.99 |
+ ------------- +
1 row in SET (1.17 Sec)

Mysql> select Min (v) from CH3;
+ ------------- +
| Min (v) |
+ ------------- +
| 1, 99999999.99 |
+ ------------- +
1 row in SET (1.17 Sec)
Mysql> select sum (v) from CH3;
+ ----------------- +
| Sum (v) |
+ ----------------- +
| 1, 819199999918.02 |
+ ----------------- +
1 row in SET (0.08 Sec)

MySQL & gt; update CH3 set V = 100000000;
Query OK, 8192 rows affected (0.12 Sec)
Rows matched: 8192 changed: 8192 Warnings: 0

Mysql> select sum (v) from CH3;
+ ----------------- +
| Sum (v) |
+ ----------------- +
| 1, 819200000000.00 |
+ ----------------- +
1 row in SET (0.06 Sec)

Mysql> Update CH3 set V = 100000000-0.01;
Query OK, 8192 rows affected (0.25 Sec)
Rows matched: 8192 changed: 8192 Warnings: 0

Mysql> select sum (v) from CH3;
+ ----------------- +
| Sum (v) |
+ ----------------- +
| 1, 819199999918.02 |
+ ----------------- +
1 row in SET (0.08 Sec)

Mysql> Update CH3 set V = 100000000 + 0.01;
Query OK, 8192 rows affected (0.23 Sec)
Rows matched: 8192 changed: 8192 Warnings: 0

Mysql> select sum (v) from CH3;
+ ----------------- +
| Sum (v) |
+ ----------------- +
| 1, 819200000081.98 |
+ ----------------- +
1 row in SET (0.09 Sec)
Mysql> select 99999999.99*8192;
+ ------------------ +
| 99999999.99*8192 |
+ ------------------ +
| 1, 819199999918.08 |
+ ------------------ +
1 row in SET (0.00 Sec)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.