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



need to split a string into separate values. eg. col1 col2 ---------- 100 - 'a,b,c&..

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

need to split a string into separate values. eg. col1 col2 ---------- 100 - 'a,b,c&..

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

Post New Answer

More SQL PLSQL Interview Questions

How do you select unique values in sql?

0 Answers  


Can I copy :old and :new pseudo-records in/to an oracle stored procedure?

0 Answers  


What is the difference between local and global temporary table?

0 Answers  


Explain the purpose of %type and %rowtype data types with the example?

0 Answers  


What is microsoft t sql?

0 Answers  






what is myisam? : Sql dba

0 Answers  


How many columns should be in an index?

0 Answers  


How to display Row Number with Records in Oracle SQL Plus?

0 Answers   MCN Solutions,


What is composite primary key in sql?

0 Answers  


what is cursor. write example of it. What are the attributes of cursor.

0 Answers  


What is meant by <> in sql?

0 Answers  


What is the difference between the sql*loader and import utilities? : aql loader

0 Answers  


Categories