Postgrel 取整函数、四舍五入函数和保留几位小数

Postgrel 取整函数、四舍五入函数和保留几位小数

 地址: https://postgres.fun/20140508101444.html

四舍五入函数

FunctionReturn TypeDescription
round(dp or numeric)(same as input)round to nearest integer
round(v numeric, s int)numericround to s decimal places

 

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)

 

取整函数

FunctionReturn TypeDescription
ceil(dp or numeric)(same as input)smallest integer not less than argument
floor(dp or numeric)(same as input)largest integer not greater than argument
返回大于或等于给出数字的最小整数

francs=>  select ceil(3.36);
 ceil 
------
 4
(1 row)
  
francs=>  select ceil(-3.36);
 ceil 
------
-3
(1 row)
返回小于或等于给出数字的最大整数

francs=>  select floor(3.36); 
 floor 
-------
3
(1 row)
  
francs=>  select floor(-3.36);
 floor 
-------
 -4
(1 row)
备注:如果没记错的话,这几个函数在 oracle 当中是通用的。

 

 地址: https://postgres.fun/20140508101444.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值