如何在oracle中四舍五入
How to rounding up in oracle
我想在 oracle 11g 中使用 round 函数将这个值“2167.124”转换为“2167.13”。问题是它转换为 LIKE "2167.12"
但我需要“2167.13”。
请帮忙,提前致谢
如果要将给定值 2167.12" 转换为 "2167.13" 请使用此
select ceil(2167.124*100)/100 来自双;
扩展 Sam 的示例,乘以 100 有效地将小数点向右移动两位,因此您的值变为 216712.4:
select 2167.124*100 as step1 from dual;
STEP1
----------
216712.4
然后你调用 ceil
找到 "the smallest integer that is greater than or equal to n":
select ceil(216712.4) as step2 from dual;
STEP2
----------
216713
然后除以 100 有效地将小数点向左移回相同的两位:
select 216713/100 as step3 from dual;
STEP3
----------
2167.13
将这三个步骤放在一个语句中得到:
select ceil(2167.124*100)/100 as result from dual;
RESULT
----------
2167.13
我想在 oracle 11g 中使用 round 函数将这个值“2167.124”转换为“2167.13”。问题是它转换为 LIKE "2167.12" 但我需要“2167.13”。
请帮忙,提前致谢
如果要将给定值 2167.12" 转换为 "2167.13" 请使用此
select ceil(2167.124*100)/100 来自双;
扩展 Sam 的示例,乘以 100 有效地将小数点向右移动两位,因此您的值变为 216712.4:
select 2167.124*100 as step1 from dual;
STEP1
----------
216712.4
然后你调用 ceil
找到 "the smallest integer that is greater than or equal to n":
select ceil(216712.4) as step2 from dual;
STEP2
----------
216713
然后除以 100 有效地将小数点向左移回相同的两位:
select 216713/100 as step3 from dual;
STEP3
----------
2167.13
将这三个步骤放在一个语句中得到:
select ceil(2167.124*100)/100 as result from dual;
RESULT
----------
2167.13