如何 trim 在 Oracle 中右转 string/number 中的两个字符

How to trim right two characters from a string/number in Oracle

我只想 trim 字符串中最右边的两个字符。

这是我想要的字段的代码 trim:

`ROUND(ifsapp.customer_order_api.get_gross_amt_incl_charges(c.order_no),-2))

例如,如果api调用returns 1136,它将四舍五入为1100。我希望最终结果为return'11'

我在 SSRS 查询编辑器中。

这应该可以完成工作

SELECT SUBSTR('your string',1,2) FROM dual;

或详细

substr(ROUND(ifsapp.customer_order_api.get_gross_amt_incl_charges(c.order_no),-2)),1,2)

您可以将您的数字除以 100 来移动比例,并对结果四舍五入:

ROUND(ifsapp.customer_order_api.get_gross_amt_incl_charges(c.order_no)/100))

有一些演示值:

with t(x) as (
  select 1136 from dual
  union all select 145 from dual
  union all select 98765 from dual
)
select x, round(x/100) as y
from t;

       X        Y
-------- --------
    1136       11
     145        1
   98765      988