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!

Level, LEAD / LAG or Perhaps Partition over multiple rows

2923313Jul 14 2015 — edited Jul 15 2015

Hi all,

I haven't encontered anything like this before, and as such am not sure how to best tackle it.

I have a table of phone calls coming into an phone system (Genesys) some of these calls are transfered between agents and queues there is a unique "Interaction_id" for each call and I can tell it's been transfered when it gets to another "login_name", unfortunely a call could potentially be transferred an infinite number of times which is where my issue is. My data looks like for a single interaction:

CAL_DATEINTERACTION_IDQUEUE_NAMELOGIN_NAME
2015-07-09 15:00:26108170179Business_Account_Unknown_vqt963092
2015-07-09 15:02:27108170179Business_MobileCalling_Resolve_Unknown_vqt955202
2015-07-09 15:03:49108170179Business_FixedLineData_Resolve_BBA_vqt820093
2015-07-09 15:15:10108170179Consumer_Unknown_Unknown_vqt951129

What I need to do is show transfers in and transfers out - the first call wouldn't be a transfer in and the last wouldn't be a transfer out, so it would look like:

CAL_DATEINTERACTION_IDQUEUE_NAMELOGIN_NAMETRANSFER_INTRANSFER_OUT
2015-07-09 15:00:26108170179Business_Account_Unknown_vqt96309201
2015-07-09 15:02:27108170179Business_MobileCalling_Resolve_Unknown_vqt95520211
2015-07-09 15:03:49108170179Business_FixedLineData_Resolve_BBA_vqt82009311
2015-07-09 15:15:10108170179Consumer_Unknown_Unknown_vqt95112910

So I think what I need to do is perhaps something like CASE WHEN xxx LEAD xxx OVER (PARTITION BY INTERACTION_ID ORDER BY CAL_DATE DESC)?

Any help appreciated.


Thanks,


Thomas

This post has been answered by 2923313 on Jul 15 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 12 2015
Added on Jul 14 2015
3 comments
1,242 views