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


Please Help Members By Posting Answers For Below Questions

Whats the benefit of dbms_stats over analyze?

1492


What is different types of joins?

570


How can you use check constraints for self referential integrity?

520


What is analyze command used for?

574


What are the roles of dba?

610






what is a Nested Loop join?

1564


Assuming today is Monday, how would you use the DBMS_JOB package to schedule the execution of a given procedure owned by SCOTT to start Wednesday at 9AM and to run subsequently every other day at 2AM.

1502


How to speed up webrick?

591


Explain how you would restore a database using RMAN to Point in Time?

1630


How to connect ms access to oracle servers?

548


Is oracle a programming language?

564


What is the difference between count (*), count (expression), count (distinct expression)?

557


What is oracle rowcount?

571


How many categories of data types?

570


How to view the data files in the current database?

592