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 an inconsistent dependency?

761


What are the different schemas objects that can be created using pl/sql?

725


How many types of literals are available in pl sql?

748


Can we connect to postgresql using sql developer?

697


What does a pl/sql package consist of?

719






What is substitution variable in pl sql?

693


how would you write a query to select all teams that won either 2, 4, 6 or 8 games? : Sql dba

1079


Does a user_objects view have an entry for a trigger?

757


What is the syntax and use of the coalesce function?

810


What is before and after trigger?

691


What are the benefits of pl sql?

765


Explain the update statement in sql

731


What are stored procedures in mysql?

760


what are the maximum number of rows that can be constructed by inserting rows directly in value list? : Transact sql

700


Does execute immediate commit?

927