write a sql query following source looking like below
column1 column2
101,102,103 abc,def,ghi
1001,1002,1003 a,b,c
i want the output
column1 column1
101 abc
102 def
103 ghi
1001 a
1002 b
1003 c
Answer Posted / farrukhshaikh
select vw1.str, vw2.str
from (select rownum sr,
substr(col,
instr(col, ',', 1, level) + 1,
instr(col, ',', 1, level + 1) -
instr(col, ',', 1, level) - 1) str
from (select ',' || qry || ',' col
from (select '101,102,103,1001,1002,1003'
qry from dual))
connect by level <= length(col) - length(replace
(col, ',')) - 1) vw1,
(select rownum sr,
substr(col,
instr(col, ',', 1, level) + 1,
instr(col, ',', 1, level + 1) -
instr(col, ',', 1, level) - 1) str
from (select ',' || qry || ',' col
from (select 'abc,def,ghi,a,b,c' qry from
dual))
connect by level <= length(col) - length(replace
(col, ',')) - 1) vw2
where vw1.sr = vw2.sr
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the data pump import utility?
What is the minimum client footprint required to connect c# to an oracle database?
Can we write insert statement in function in oracle?
How to create a stored function in oracle?
What is object data modeling?
How can we find out the current date and time in oracle?
Difference between pre-select and pre-query
How to login to the server without an instance?
What to do if dba lost the system password?
Can you create a synonym without having a table?
Explain the importance of .pll extension in oracle?
What is difference between sid and service name in oracle?
How to start an oracle instance?
What is dual table oracle?
How to retrieve values from data fields in record variables?