--MSSql 保留两位小数的用法
1: round(@sum,2),
2: Convert(decimal(18,2),@sum)

select round(9,2)                                 --9 是想要的效果
select round(9.1248,2)                        --9.1200 不是想要的效果

select Convert(decimal(18,2),9)          --9.00不是想要的效果 不想补0
select Convert(decimal(18,2),9.1248) --9.12是想要的效果

select cast(round(9, 2) as float)          --9是想要的效果
select cast(round(9.1248, 2) as float) --9.12 是想要的效果

posted on 2019-09-06 10:23  丶愤怒的蘑菇  阅读(2803)  评论(0编辑  收藏  举报