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 |
if a table is getting updated what happens if a function is called from sql query?
trans_id trans_date trans_amt debit_credit_indicator 001 01-JAN-13 1099 cr 001 12-JAN-13 500 db 002 24-FEB-13 400 db 002 23-MAR-13 345 cr 001 18-APR-13 800 cr 002 15-MAR-13 600 db 001 12-FEB-13 200 cr i want like this output trans_id trans_date trans_amt debit_credit_indicator 001 JAN 1599 cr no.of trans 2 i want trans_id and trans_date like 'JAN' or 'FEB' etc, trans_amt i want all credit amount - debit amount per each trans_id. and debit_credit_indicator and no.of transactions in a month.
How does an execution block start and end in pl sql?
What is sql scripting?
What is a cursor ? Why Cursor is required ?
we have a package and we have grants to execute that package inside of that we have table, here we don't have privileges to this table? whether this package will execute or not?
Can a primary key be a foreign key?
What is denormalization in a database?
What is trigger price?
What is difference between table and view?
What is the location of pre_defined_functions.
can i create trigger on synonym is it possible or not please help me