Splitting amount using comma in oracle

佐手、 提交于 2019-12-24 15:27:53

问题


In oracle i need to split amount using comma such as 10,000 and 1,00,000 whatever it comes. I need to split this. Is there any solution available for this. Am stuck with this. my result set is comes as 1000 and 10000 etc..


回答1:


Use TO_CHAR and desired number format.

SQL> with data(num) as(
  2  select 100 from dual union
  3  select 1000 from dual union
  4  select 10000 from dual union
  5  select 1000000 from dual
  6  )
  7  SELECT TO_CHAR(num, '9,999,999') FROM data;

Also, in SQL*Plus there is a default number format. You could set numformat as per your desired format:

SQL> set numformat 9,99,999
SQL> SELECT 100000 FROM DUAL;

   100000
---------
 1,00,000

TO_CHAR(NU
----------
       100
     1,000
    10,000
 1,000,000


来源:https://stackoverflow.com/questions/33145216/splitting-amount-using-comma-in-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!