sql2008中如何截取小数(sql截取小数点后几位)

sql2008中如何截取小数(sql截取小数点后几位)

首页维修大全综合更新时间:2024-05-07 22:32:37

sql2008中如何截取小数

sqⅠ2008中截取小数可用convert函数或cast函数。具体用法如下:

方法一:convert(float,字段名) as 别名

select convert(float,round(10.123232,2))

结果:10.12

select convert(float,round(10,2))

结果:10

方法二:cast(round(字段名,2) as numeric(20,2)) as 别名

select cast(round(10.123232,2) as numeric(20,2))

结果:10.12

select cast(round(10,2) as numeric(20,2))

结果:10.00

方法一和方法二输出结果不同,可以根据实际场景选择使用的方法

大家还看了
也许喜欢
更多栏目

© 2021 3dmxku.com,All Rights Reserved.