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.
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / 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 |
What are the two types of cursors in pl sql?
how to drop an existing table in mysql? : Sql dba
What is the difference between a procedure and a function?
Explain spool.
Explain the update statement in sql
Write a sql query to find the names of employees that begin with ‘a’?
How can we connect an Android App to an Oracle database and use the PL/SQL procedural code?
what are the demerits of sql?
Can we change the table name in sql?
Is sql easier than java?
Which type of cursor is used to execute the dml statement?
What is user in sql?