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 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 the current version of sql?

1104


Can delete statement be rollbacked?

1064


Does group by remove duplicates?

1118


What is your daily office routine?

2351


How do I remove duplicates in two columns?

1201


what are all the common sql function? : Sql dba

1140


what is schema? : Sql dba

1160


Is primary key clustered index?

1025


Do we need to rebuild index after truncate?

1151


define sql insert statement ? : Sql dba

1107


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

1123


What is the best sql course?

1061


how many tables will create when we create table, what are they? : Sql dba

1153


Can we use distinct and group by together?

1145


What is the current version of postgresql?

1187