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

What are the two types of cursors in pl sql?

0 Answers  


how to drop an existing table in mysql? : Sql dba

0 Answers  


What is the difference between a procedure and a function?

0 Answers  


Explain spool.

0 Answers  


Explain the update statement in sql

0 Answers  






Write a sql query to find the names of employees that begin with ‘a’?

0 Answers  


How can we connect an Android App to an Oracle database and use the PL/SQL procedural code?

0 Answers  


what are the demerits of sql?

1 Answers  


Can we change the table name in sql?

0 Answers  


Is sql easier than java?

0 Answers  


Which type of cursor is used to execute the dml statement?

0 Answers  


What is user in sql?

0 Answers  


Categories