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 does pl sql work?

1 Answers  


What are pl sql procedures?

1 Answers  


what is bcp? When does it used? : Sql dba

0 Answers  


What is sqlcontext?

1 Answers  


What are the advantages of normalization?

1 Answers  


What are the benefits of pl/sql packages?

1 Answers  


write a query to display diference between two dates in sql server

2 Answers  


can we call a procedure into another procedure?If yes means how you can pass the perameters for the two procedures?

2 Answers   Fujitsu,


Write a query to find the employees from EMP table those who have joined in Monday. (there is a column as hiredate which is a date column i.e values are like 03-DEC-81)

5 Answers  


Which are the different character-manipulation functions in sql?

1 Answers  


i have a word ***********hello********world******. I require a o/p **********hello world**********, Need to delete the middle stars.

3 Answers  


What are the types of dbms?

1 Answers  


Categories