Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Please ask technical questions in the appropriate category. Thank you!

concatenate strings in cumulative fashion

870716May 5 2014 — edited May 7 2014

Dear Experts,

I have a table that stores orders information placed by customers. It stores Customer Id, Order Id, Order Date and Shipped Date. I need to write a sql query that gives me the previous/history of order date and shipped date in this format shown below.If there are more than 10 orders per customer then I only need the previous 10 order and shipped date.

Customer_IDOrder_IDOrder_DateShipped_Date
C1O11/1/20137/1/2013
C1O228/01/201330/01/2013
C1O318/04/201322/04/2013
C1O414/07/201316/07/2013
C1O52/8/20134/8/2013

Output:

Customer_IDOrder_IDH_OrderDateH_ShippedDate
C1O1NULLNULL
C1O20101201307012013
C1O328012013;0101201330012013;07012013
C1O418042013;28012013;0101201322042013;30012013;07012013
C1O514072013;18042013;28012013;0101201316072013;22042013;30012013;07012013

Before posting my question here, I have tried using lead, lag and listagg functions but i'm unable to frame the query that gives the output I am looking for. Any help would be greatly appreciated.

I am using oracle 11g.

Thank You.

This post has been answered by michaelrozar17 on May 5 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 4 2014
Added on May 5 2014
5 comments
2,475 views