Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

regexp_substr and connect by level.

879642Aug 18 2011 — edited Aug 18 2011
Hi

I have a a below query and out put also given below

Query:

select distinct cont_id,ct.TAG245 from contact_tag ct where ct.CONT_ID='AEGA-3R43UM'

OUTPUT

Cont_id TAG245
AEGA-3R43UM 060|02.00|060|02.00|060|02.00|060|02.00

In the above output for TAG245 we have two values first value is percentage and second value is frequency.

I need to make all frequency values sum.(ie 02.00+02.00+02.00+02.00)

Expected output

Plannedcall
6


********************

Step 1
First I am approaching the above output dividing the each pipe symbols into each row using the below query but it is not working it is taking long time.Can you advice me on this so that i can goto next step:2.


The query
SELECT regexp_substr (ct.TAG245, '[|,]+', 1, level) frequency
FROM contact_tag ct
--where ct.CONT_ID='AEGA-3R43UM'
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (ct.TAG245, '[|,]+')) + 1
order by 1;



Step: 2
Once i get the output I will sum the even rows because all evenrows has frequency values.



Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 15 2011
Added on Aug 18 2011
3 comments
3,328 views