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
What are the types of queries in sql?
What are the advantages of indexing?
Is join an inner join?
how to get @@error and @@rowcount at the same time? : Sql dba
Does sql backup shrink transaction log?
What is sqlcommand?
What are pl/sql cursor exceptions?
What is rollback?
What are character functions?
What is optimistic concurrency control? : Transact sql
What is a clob in sql?
Is ms sql is free?
Can you load data into multiple tables at once? : aql loader
What is the use of non clustered index?
Is it possible to Restore a Dropped Table using Rollback Command in Oracle SQL Plus ?