`
ch.net
  • 浏览: 112343 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

保留两位小数,并只舍不入 舍弃数字后面无用的0和点

    博客分类:
  • SQL
 
阅读更多

保留两位小数,并只舍不入

 1. declare @a decimal(18,12)

set @a = 3.21969

select cast(@a - 0.005 as decimal(18,2))

 2. select round(3.21969, 2,1)

结果 3.21

舍弃数字后面无用的0和点

1.   select cast(1.20 as real) select cast(1.00 as real)

2.   1.20.ToString("G")

   1.00.ToString("G")

   结果  1.2 1

3.  1.20.ToString("#.######")

   1.00.ToString("#.######")

   结果  1.2 1

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics