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.

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is memory optimized table?

583


What do we need to check in database testing?

565


How many joins in sql?

568


How do you concatenate in sql?

561


What is the difference between joins?

546






Explain aggregate functions are available there in sql?

545


How many triggers can be applied on a table?

523


How does a self join work?

528


what are the differences between char and varchar? : Sql dba

539


What is java sql package?

549


Can there be more than one function with a similar name in a pl/sql block?

559


what is the difference between mysql_fetch_array and mysql_fetch_object? : Sql dba

565


What is on delete restrict?

546


What are the indexing methods?

591


What is data type in sql?

566