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

What is currency type in database ?

3 Answers   TCS,


Why does Oracle not permit the use of PCTUSED with indexes?

0 Answers  


defination of bitmap index

0 Answers   NIIT,


write a query to count number of alphabets in given string for example "APPLE" write a query to generate sequence from 50 to 100 write a query to display in single string "ABCD,EFGH,IJKL,PQRS"

7 Answers   British Telecom BT,


I'm doing my final year and i ve planned to do an oracle certification , is this the rit tim nd wat's the future scope??

1 Answers  






How to download oracle database 10g xe?

0 Answers  


What is difference between Rename and Alias?

1 Answers  


How to retrieve first and last records from a table?

7 Answers   DELL, QSmart,


What are the factors that affect OPTIMIZER in choosing an Optimization approach ?

2 Answers  


What is the data type of dual table?

0 Answers  


Which Functions Using Integer ==> String's i.e 2 ==> Two... Like that string's ==> integer values ? It is Possible ?

2 Answers   Oracle, SAH,


i have a table and it has constraints and i want to get "ALTER TABLE table_name ADD CONSTRAINT constraint_name constraint type" this code must be in string type please help me if you want, i can give more explainings

2 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • 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)