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 are the types of queries in sql?

514


What are the advantages of indexing?

513


Is join an inner join?

531


how to get @@error and @@rowcount at the same time? : Sql dba

522


Does sql backup shrink transaction log?

546






What is sqlcommand?

546


What are pl/sql cursor exceptions?

567


What is rollback?

574


What are character functions?

623


What is optimistic concurrency control? : Transact sql

539


What is a clob in sql?

558


Is ms sql is free?

526


Can you load data into multiple tables at once? : aql loader

595


What is the use of non clustered index?

524


Is it possible to Restore a Dropped Table using Rollback Command in Oracle SQL Plus ?

711