plsql - 如何通过某个 Round up 因子进行 Roundup?
问题描述
If x = 1.71 Then output = 1
If x = 1.82 Then output = 2
我的综合因素是0.8
如何在 Oracle 存储过程计算中实现这一点?
解决方案
从您提供的最小示例中,您希望ceil()
使用调整后的值:
ceil(x - 0.8)
在 CTE 中包含一些示例值的演示:
with t (x) as (
select 1.5 + (level - 1)/10 from dual connect by level <= 5
union all select 1.71 from dual
union all select 1.78 from dual
union all select 1.79 from dual
union all select 1.81 from dual
union all select 1.82 from dual
)
select x, ceil(x - 0.8)
from t
order by x;
X CEIL(X-0.8)
---------- -----------
1.5 1
1.6 1
1.7 1
1.71 1
1.78 1
1.79 1
1.8 1
1.81 2
1.82 2
1.9 2
目前还不清楚 1.8 会发生什么。
在 PL/SQL 中你可以做同样的事情:
y := ceil(x - 0.8);
推荐阅读
- python-3.x - 尝试使用 python3.cryptography 自动生成证书;没有运气
- dialogflow-es - 如何使用 Transactions API 进行非付费餐桌预订谷歌操作?
- node.js - 在节点上执行在 Postman 上测试的等效请求
- delphi - 在 Delphi 7 中使用 avicap32 从网络摄像头捕获图像
- python - 获取pandas GroupBy中最大值对应的行
- azure - New-AzureRmWebAppBackup cmdlet 返回“超出允许的备份数”
- php - MercadoPago 订单更新 IPN
- mysql - 将 2 个 sql 查询合并为 1 个查询
- c++ - bench/BenchTimer.h (31) 语法错误:'volatile'
- typescript - Array.sort 在 Nativescript iOS 上无法正常工作,用于具有大量数字的非常大的数组