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 not equal in sql?

511


What is consistency?

715


What are the different operators available in sql?

576


Is nosql faster than sql?

542


What are the query optimization techniques?

535






What is sql clause?

543


What is java sql driver?

550


Is pl sql and postgresql same?

573


Can we change the table name in sql?

532


What is the difference between sql and t sql?

537


What are all the common sql functions?

564


how can you see all indexes defined for a table? : Sql dba

537


What are properties of the transaction?

560


What does subquery mean in sql?

542


how can we know the count/number of elements of an array? : Sql dba

576