• 技术文章 >数据库 >PostgreSQL

    PostgreSQL如何四舍五入

    月亮邮递员月亮邮递员2020-04-02 15:04:36原创8006

    PostgreSQL如何四舍五入

    PostgreSQL四舍五入函数如下:

    1、round(dp or numeric),将四舍五入到最接近的整数;

    2、round(v numeric, s int) 四舍五入到s位小数位。

    微信截图_20200402145744.png

    使用示例:

    francs=>  select round(10.2);
     round 
    -------
     10
    (1 row)
      
    francs=>  select round(10.9);
     round 
    -------
     11
    (1 row)
      
    francs=>  select  10.1/3;
     ?column? 
    --------------------
    3.3666666666666667
    (1 row)
      
    francs=>  select round(10.1/3);
     round 
    -------
    3
    (1 row)
      
    francs=>  select round(10.1/3,2);
     round 
    -------
     3.37
    (1 row)

    推荐:PostgreSQL教程

    专题推荐:postgresql 四舍五入 方法
    品易云
    上一篇:PostgreSQL数组怎么添加元素 下一篇:PostgreSQL出现认证失败怎么办

    相关文章推荐

    • PostgreSQL运行不起来怎么办• PostgreSQL数组怎么添加元素

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网