品易云推流 关闭
文章详情页
文章 > PostgreSQL > PostgreSQL如何四舍五入

PostgreSQL如何四舍五入

头像

月亮邮递员

2020-04-02 15:04:368534浏览 · 0收藏 · 0评论

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教程

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图