Wednesday, 17 May 2017

Separating Values from One Column to Multi Columns Using INSTR

Let's say we got requirement as below.

String: 'Venky,Teja,Bangalore' --its one of the column value , now i want it to be shown as 3 different columns.

Col1     Col2     Col3
Venky   Teja      Bangalore


Lets take one eg:

create table trans( t_id integer, txn_desc varchar2(400));

SQL> insert into trans  values (1,'Amount,Piad_by,Cash');

1 row inserted

SQL> insert into trans  values (2,'Amount,Piad_by,Credit card');

1 row inserted

SQL> insert into trans  values (3,'Amount,Piad_by,Debit card');

1 row inserted

SQL> commit;

Commit complete


Output in Required Format




No comments:

Post a Comment