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

What is spool?

586


how to create a test table in your mysql server? : Sql dba

489


Is time a data type in sql?

474


what is the use of set statement in tsql? : Transact sql

523


Is it possible for a table to have more than one foreign key?

575






What is the difference between instead of trigger and after trigger?

502


Give the order of sql select?

603


What are the sql versions?

512


What is the use of sqlerrd 3?

515


What is the best sql course?

526


What are different types of indexes?

506


What is a native sql query?

488


How can I change database name in sql?

521


What is $$ in sql?

547


What are the differences between implicit and explicit cursors?

513