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



write a sql query following source looking like below column1 column2 101,102,103 ..

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

Post New Answer

More Oracle General Interview Questions

Explain a data segment?

0 Answers  


can anyody please send me the dump for Oracle 10g certifications for DBA path?

0 Answers  


what is the maximum number of indexes i can create for a table? What happens if i create indexes for all the columns of a table? Will it slow down the speed of retrieval

2 Answers  


Query to retrieve record for a many to many relationship ?

0 Answers   Keane India Ltd,


i deleted 4 records form the table.after i have applied commit .now i want to get back those records.how?

7 Answers   HCL, IBM,


What is an oracle database table?

0 Answers  


How would you best determine why your MVIEW couldnt FAST REFRESH?

0 Answers  


What is meant by an index?

0 Answers  


How to select oracle sequence from different schema and How to select oracle sequence from different Databases. Explain with example

1 Answers   Polaris,


How to enter a new row into a table interactively?

0 Answers  


What is a Sequence ?

3 Answers  


How do I uninstall oracle client from windows?

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1808)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)