【问题标题】:How to remove the decimal and take only the whole number? [duplicate]如何去掉小数只取整数? [复制]
【发布时间】:2015-11-25 13:57:09
【问题描述】:

我有 output = "70.00" 我只想通过 SQL 服务器获得 "70"

【问题讨论】:

  • 70.67 你想要什么?
  • 声明@i decimal(5,2)=70.00 select cast(@i as int)
  • 您使用引号,70.00 是小数还是字符串?
  • 您必须决定是要将round 十进制数转换为整数还是只想truncate 小数部分的小数部分?

标签: sql sql-server sql-server-2008 decimal


【解决方案1】:

在sql server中使用ROUND()(See examples)函数

select cast(round(70.0,0) as int)

【讨论】:

    【解决方案2】:

    尝试使用

    SELECT FLOOR(70.00)
    

    SELECT CAST(70.00 AS INT)
    

    【讨论】:

      猜你喜欢
      • 2020-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多