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
Can we use having without group by in sql?
What is view explain with example?
What is a record in a database?
What program will open a mdb file?
What is data type in sql?
what is the difference between a web-garden and a web-farm? : Sql dba
Explain about various levels of constraint.
What is the purpose of cursors in pl/sql?
Write a sql query to find the names of employees that begin with ‘a’?
Why do we use cursors?
Advantages and disadvantages of stored procedure?
Mention what are the benefits of pl/sql packages?
Is left join and outer join same?
Is it possible to create the following trigger: before or after update trigger for each row?
How we can create a table in pl/sql block. Insert records into it? Is it possible by some procedure or function? Please give example?