need to split a string into separate values.

eg.

col1 col2
----------
100 - 'a,b,c'
200 - 'a,x,d,e'
300 - 'c'

result:
value count
-------------
a - 2
b - 1
c - 2
etc.

Answers were Sorted based on User's Feedback



need to split a string into separate values. eg. col1 col2 ---------- 100 - 'a,b,c&..

Answer / sharath sn

substr('a,b,c',',',instr('a,b,c',',',1,1)-1)
,substr('a,b,c',instr('a,b,c',',',1,1)+1,instr
('a,b,c',',',2,1)-instr('a,b,c',',',1,1)-1)
,substr('a,b,c',instr('a,b,c',',',2,1)-1);

Is This Answer Correct ?    2 Yes 5 No

need to split a string into separate values. eg. col1 col2 ---------- 100 - 'a,b,c&..

Answer / sharath

select count(substr('a,b,c',',',instr('a,b,c',',',1,1)-1))
,count(substr('a,b,c',instr('a,b,c',',',1,1)+1,instr
('a,b,c',',',2,1)-instr('a,b,c',',',1,1)-1))
,count(substr('a,b,c',instr('a,b,c',',',2,1)-1)) from
table_name;

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More SQL PLSQL Interview Questions

if a table is getting updated what happens if a function is called from sql query?

2 Answers   RBS,


trans_id trans_date trans_amt debit_credit_indicator 001 01-JAN-13 1099 cr 001 12-JAN-13 500 db 002 24-FEB-13 400 db 002 23-MAR-13 345 cr 001 18-APR-13 800 cr 002 15-MAR-13 600 db 001 12-FEB-13 200 cr i want like this output trans_id trans_date trans_amt debit_credit_indicator 001 JAN 1599 cr no.of trans 2 i want trans_id and trans_date like 'JAN' or 'FEB' etc, trans_amt i want all credit amount - debit amount per each trans_id. and debit_credit_indicator and no.of transactions in a month.

1 Answers   Oracle,


How does an execution block start and end in pl sql?

0 Answers  


What is sql scripting?

0 Answers  


What is a cursor ? Why Cursor is required ?

3 Answers  






we have a package and we have grants to execute that package inside of that we have table, here we don't have privileges to this table? whether this package will execute or not?

3 Answers   TCS,


Can a primary key be a foreign key?

0 Answers  


What is denormalization in a database?

0 Answers  


What is trigger price?

0 Answers  


What is difference between table and view?

0 Answers  


What is the location of pre_defined_functions.

0 Answers  


can i create trigger on synonym is it possible or not please help me

4 Answers   CGI,


Categories