user5122076
user5122076

Reputation:

Splitting amount using comma in oracle

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..

Upvotes: 1

Views: 63

Answers (1)

Lalit Kumar B
Lalit Kumar B

Reputation: 49092

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

Upvotes: 1

Related Questions