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 |
How to convert characters to dates in oracle?
what is the output of select * from emp where null=null & select * from emp where 1=1
how can get like this result table A col1 col2 --- ----- a A b B C C .. .. .. ... .. ... wants result like for a single column col1 ------ a,b,c,........n of data and another is col1 ------- A B C D ........ a b b d ........
What is the disadvantage of User defind function?
How to create an oracle database?
What happens if you set the sga too low in oracle?
How do I know if oracle client is installed on windows?
Difference between hot backup vs. Cold backup?
which clause we are not used in where clause?
Can we protect our pl/sql source code?
what is Materialized view? What is a snapshot? what are the similarities and differences between Materialized views and snapshots?
nw i'm doing MBA system and planning to do oracle,database management.tell me that whether it is useful r not?.refer any course for my carrier pls