您的当前位置:首页正文

SqlServer中截取小数位数

来源:个人技术集锦
SqlServer中截取⼩数位数

⽅法⼀: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

⽅法⼀和⽅法⼆输出结果不同,可以根据实际场景选择使⽤的⽅法

因篇幅问题不能全部显示,请点此查看更多更全内容