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
Whats the benefit of dbms_stats over analyze?
What is different types of joins?
How can you use check constraints for self referential integrity?
What is analyze command used for?
What are the roles of dba?
what is a Nested Loop join?
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.
How to speed up webrick?
Explain how you would restore a database using RMAN to Point in Time?
How to connect ms access to oracle servers?
Is oracle a programming language?
What is the difference between count (*), count (expression), count (distinct expression)?
What is oracle rowcount?
How many categories of data types?
How to view the data files in the current database?