PostgreSQL如何四舍五入

1,850次阅读
没有评论

PostgreSQL如何四舍五入

PostgreSQL如何四舍五入

PostgreSQL四舍五入函数如下:

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

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

PostgreSQL如何四舍五入

使用示例:

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

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:postgresql2022-12-02发表,共计428字。
新手QQ群:570568346,欢迎进群讨论 Python51学习