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 / 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 |
Explain the use of log option in exp command.
how to select second mauximum value in a given table under salary column
Display those managers salary greater than the average salary of his employees?(Based on oracle standard Emp table)
query to find the maximum no persons with same age(age colomn) from emp table
Give the various exception types.
How to create lov dynamically at runtime & attach to text field?
Why does Oracle not permit the use of PCTUSED with indexes?
What is a Temporary Segment ?
WHAT IS THE DEFINITION OF DEFAULT CUSTOMER IN AR?
How can we find out the current date and time in oracle?
Can the query output be sorted by multiple columns in oracle?
How to use fetch statement in a loop?