If x = 1.71 Then output = 1
If x = 1.82 Then output = 2
我的综合系数是0.8
如何在Oracle存储过程计算中实现这一目标?
答案 0 :(得分:2)
从给出的最少示例中,您想使用调整后的值Sub Files()
ActiveWorkbook.SaveCopyAs "C:\Users\" & Environ("Username") & "\Desktop\testfile.xlsm"
Workbooks.Open "C:\Users\" & Environ("Username") & "\Desktop\" & "testfile.xlsm", UpdateLinks:=False
ThisWorkbook.Close SaveChanges = False
MsgBox ("File saved successfully on desktop.")
End Sub
:
MsgBox ("File saved successfully on desktop.")
在CTE中包含一些样本值的演示
ceil()
目前还不清楚1.8将会发生什么。
在PL / SQL中,您可以执行相同的操作:
ceil(x - 0.8)
答案 1 :(得分:2)
使用ROUND
和.5
的偏移量。因此,对于您的0.8
因子,然后0.5 = 0.8 - 0.3
就这样从您的值中减去0.3
:
Oracle 11g R2架构设置:
CREATE TABLE table_name ( value ) AS
SELECT +1.71 FROM DUAL UNION ALL
SELECT +1.80 FROM DUAL UNION ALL
SELECT +1.81 FROM DUAL UNION ALL
SELECT -1.19 FROM DUAL UNION ALL
SELECT -1.20 FROM DUAL;
查询1 :
SELECT value,
ROUND( value - 0.3 ) AS rounded_value
FROM table_name
Results :
| VALUE | ROUNDED_VALUE |
|-------|---------------|
| 1.71 | 1 |
| 1.8 | 2 |
| 1.81 | 2 |
| -1.19 | -1 |
| -1.2 | -2 |
根据要在舍入因子边界处处理值的方式,有使用ROUND
,FLOOR
和CEIL
的不同方法,它们分别在边界值处给出不同的结果:< / p>
ROUND( value - 0.3 )
将在远离0的边界取整-向上取正值,向下取负值。CEIL( value - 0.8 )
将使边界处的值向下取整。FLOOR( value + 0.2 )
将使边界处的值向上取整。查询2 :
SELECT value,
ROUND( value - 0.3 ) AS rounded_value,
CEIL( value - 0.8 ) AS ceiling_value,
FLOOR( value + 0.2 ) AS floored_value
FROM table_name
Results :
| VALUE | ROUNDED_VALUE | CEILING_VALUE | FLOORED_VALUE |
|-------|---------------|---------------|---------------|
| 1.71 | 1 | 1 | 1 |
| 1.8 | 2 | 1 | 2 |
| 1.81 | 2 | 2 | 2 |
| -1.19 | -1 | -1 | -1 |
| -1.2 | -2 | -2 | -1 |
| -1.21 | -2 | -2 | -2 |