Discover the calculation error of the SUM function of mysql 4.0.18 for NT

xiaoxiao2021-03-06  51

Discover the calculation error of the SUM function of mysql 4.0.18 for NT 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) | ------------- | 99999999.99 | ------------- 1 ROW IN Set (1.17 sec)

MySQL> SELECT MIN (V) from Ch3; ​​ ----------- | min (v) | ------------- | 99999999.99 | ------------- 1 ROW in set (1.17 sec) mysql> select sum (v) from ch3; ------------- | SUM (V) | ----------------- | 819199999918.02 | ---------------- 1 ROW IN set (0.08 sec)

Mysql> Update CH3 set v = 100000000; Query Ok, 8192 Rows Affected (0.12 Sec) Rows Match: 8192 Changed: 8192 Warnings: 0

Mysql> Select Sum (V) from Ch3; ​​ --------------- | SUM (V) | -------------- --- | 81920000000000.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 match: 8192 changed: 8192 Warnings: 0

Mysql> Select Sum (V) from Ch3; ​​ --------------- | SUM (V) | -------------- --- | 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 Match: 8192 Changed: 8192 Warnings: 0

转载请注明原文地址:https://www.9cbs.com/read-111212.html

New Post(0)