当2位小数(30,10)数在SQL Server 05分,最后2位小数似乎迷路(甚至没有四舍五入,只需截断)。
例如:
Declare @x decimal(30,10)
Declare @y decimal(30,10)
Declare @z decimal(30,10)
select @x = 2.1277164747
select @y = 4.8553794574
Select @z = @y/@x
select @z
结果:2.28196731 00
但是,如果2号被划分转换为浮动,似乎工作:
....
Select @z = cast(@y as float)/cast(@x as float)
select @z
结果:2.28196731 81
为什么在SQL这样做呢? 什么是小数除以没有在SQL失去精度的正确方法。