adspace


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 the best sql course?

1064


how to start mysql server? : Sql dba

1279


Is primary key always clustered index?

1101


Is inner join faster than left join?

1287


what are all the common sql function? : Sql dba

1141


Can delete statement be rollbacked?

1065


If a cursor is open, how can we find in a pl/sql block?

1252


Do we need to rebuild index after truncate?

1154


Is primary key clustered index?

1028


what are the advantages of sql ? : Sql dba

1154


how to escape special characters in sql statements? : Sql dba

1124


Hi am new to PLSQL & facing problems in writing code like in SP, Functions, so any one having some SP coding with in depth explanation please share with me my Email ID suvarnaatsuvarna@rediffmail.com Or taking tanning on this please do contact me

2102


What is your daily office routine?

2353


what are aggregate and scalar functions? : Sql dba

1142


what is schema? : Sql dba

1163