【问题标题】:In clickhouse, how to round half up when casting to decimal在clickhouse中,如何在转换为小数时四舍五入
【发布时间】:2021-09-14 02:19:20
【问题描述】:

当我cast(2.555555 as Decimal64(2))时,clickhouse直接将小数部分截掉到2.55,如何将一半四舍五入到2.56?目前我必须在转换之前调用 round() 函数。

【问题讨论】:

    标签: clickhouse


    【解决方案1】:
    SELECT CAST(round(2.555555, 2), 'Decimal64(2)') AS r
    
    /*
    ┌────r─┐
    │ 2.56 │
    └──────┘
    */
    

    【讨论】:

      猜你喜欢
      • 2023-03-24
      • 1970-01-01
      • 2018-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多