Excel MSsql 不同的值
Excel MSsql different values
我创建了一个名为:
的 table
sub
,字段:
addn numeric (24,6) NULL
我已使用此 txt 文件中的值进行插入。
https://drive.google.com/file/d/1z2ixHDOvHiM5bqDSI3fCbkuXa0Syfjrn/view
问题:
为什么如果我查询这个:
select SUM(addn) from sub
结果:
131546008007.610000
如果我将结果粘贴到 Excel:
select * from sub
总和是:
131546008007.57
注意:
查询中有 4 (-0.01)。我不知道这是否触发以及如何解决这个问题
这是关于精度、比例和长度的话题。例如,数字数据类型 stored/managed 不同于浮点数据类型。
试试这个查询,你会得到与 Excel:
相同的结果
select sum(cast(addn as float)) from sub
131546008007.57
这里有一些链接在解释浮点数据类型是一个近似数字,小数比浮点数据类型更准确。所以你可以看到 Excel 使用的是近似数字。
Here 他们解释说在金融应用程序中你不应该使用浮点数据类型,所以你在你的数据库中使用 numeric
是好的,因此你可以依靠你的SQL 本例中的数据库。
并且 here 他们声明:
Excel was designed in accordance to the IEEE Standard for Binary Floating-Point Arithmetic (IEEE 754). The standard defines how floating-point numbers are stored and calculated. The IEEE 754 standard is widely used because it allows-floating point numbers to be stored in a reasonable amount of space and calculations can occur relatively quickly.
.
Excel store 15 significant digits of precision.
我创建了一个名为:
的 tablesub
,字段:
addn numeric (24,6) NULL
我已使用此 txt 文件中的值进行插入。 https://drive.google.com/file/d/1z2ixHDOvHiM5bqDSI3fCbkuXa0Syfjrn/view
问题: 为什么如果我查询这个:
select SUM(addn) from sub
结果:
131546008007.610000
如果我将结果粘贴到 Excel:
select * from sub
总和是:
131546008007.57
注意: 查询中有 4 (-0.01)。我不知道这是否触发以及如何解决这个问题
这是关于精度、比例和长度的话题。例如,数字数据类型 stored/managed 不同于浮点数据类型。
试试这个查询,你会得到与 Excel:
相同的结果select sum(cast(addn as float)) from sub
131546008007.57
这里有一些链接在解释浮点数据类型是一个近似数字,小数比浮点数据类型更准确。所以你可以看到 Excel 使用的是近似数字。
Here 他们解释说在金融应用程序中你不应该使用浮点数据类型,所以你在你的数据库中使用 numeric
是好的,因此你可以依靠你的SQL 本例中的数据库。
并且 here 他们声明:
Excel was designed in accordance to the IEEE Standard for Binary Floating-Point Arithmetic (IEEE 754). The standard defines how floating-point numbers are stored and calculated. The IEEE 754 standard is widely used because it allows-floating point numbers to be stored in a reasonable amount of space and calculations can occur relatively quickly.
.
Excel store 15 significant digits of precision.