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 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I run a sql script?

516


Differentiate between % rowtype and type record.

734


how tsql statements can be written and submitted to the database engine? : Transact sql

534


Difference between truncate, delete and drop commands?

559


How do I view a table in sql?

545






How do rank () and dense_rank () differ?

522


how to use regular expression in pattern match conditions? : Sql dba

525


What is the use of nvl function?

619


define sql insert statement ? : Sql dba

550


Where the sql database files are stored?

491


How does index help in query performance?

565


how to show all tables with 'mysql'? : Sql dba

610


How do I restart sql?

526


What are all types of user defined functions?

532


What is sql data?

552