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
Is oracle a programming language?
How to delete multiple rows from a table in oracle?
Can we create database in oracle using command line ?
How to convert csv to table in oracle?
What privilege is needed for a user to query tables in another schema?
How to retrieve values from data fields in record variables?
How to experiment a data lock in oracle?
What happens internally when the user types userID/password@string in SQL PLUS Thanks-Bhaskar
What are the execution control statements in oracle?
How to convert times to characters in oracle?
How to login to the server without an instance?
How to drop an existing table in oracle?
Explain user account with reference to oracle.
How to connect ms access to oracle servers?
Explain constraining triggers.