转载地址: http://www.2c to.com/database/201208/145053.html
SQL的数值将小数点四舍五入,留下2位。 1.round ) )函数用于四舍五入,第一个参数是要处理的数据,第二个参数设置四舍五入后小数点显示的位数。 2.numeric函数的两个参数第一个表示数据长度,第二个表示小数位数。 示例: www.2cto.comselectcast(round ) 12.5,2 ) as numeric(5) 5,2 ) )结果: 12.56selectcast(round ) 12.555,2 ) as numm 2 ) asnumeric ) 5,2 ) )结果: 122.53selectcast ) round 65222.5255,2 ) asnument原因为1222.5255,整数为4,小数为2,合4(2=6)
注:由于仅通过round (12.555,2 )获得的值为12.560,因此需要通过cast函数进行转换。