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!

Split row based on total ordered quantity

user651567Mar 28 2014 — edited Mar 28 2014

Hi All,

I want to split the row based on the the order quantity .

I have this below query which is now coming in single row.

select oel.ordered_quantity,oel.option_number,OEL.line_id,OHL.ORDER_NUMBER,OHL.order_number||'-'||'0'||OEL.LINE_NUMBER

         || DECODE (oel.shipment_number,

                    NULL, NULL,

                    '0' || oel.shipment_number||'00000')

         || DECODE (oel.option_number, null, '1', oel.option_number)

            line_shipment_option_number from OE_ORDER_LINES_ALL OEL, OE_ORDER_HEADERS_ALL OHL

            WHERE

            OEL.HEADER_ID = OHL.HEADER_ID

            --AND OHL.HEADER_ID='2028'

            and OEL.LINE_ID --= 33679

            in ( select  substr(substr(attribute1,instr(attribute1,'||',1,2),9),3)from po_lines_all where attribute1 is not null)

            and rownum <= (select sum(oe.ordered_quantity) from OE_ORDER_LINES_ALL OE, OE_ORDER_HEADERS_ALL OH

            --connect by prior <=(select sum(oe.ordered_quantity) from OE_ORDER_LINES_ALL OE, OE_ORDER_HEADERS_ALL OH

           WHERE

            OE.HEADER_ID = OH.HEADER_ID

            and oh.header_id=ohl.header_id

            group by     OH.header_id, OE.header_id )

            and ohl.org_id = 82

           order by ohl.order_number;

out put:

Ordered Qty

2         33682    10001125    10001125-0101000001

1    2    33848    10001151    10001151-0101000002

1    6    33850    10001151    10001151-0101000006

5    10    33852    10001151    10001151-01010000010

1    4    33849    10001151    10001151-0101000004

1    8    33851    10001151    10001151-0101000008

1    2    33869    10001154    10001154-0101000002

1    4    33870    10001154    10001154-0101000004

1    11    34522    10001157    10001157-01010000011

1   34504    10001157    10001157-0101000001

but in the above output we can see the order qty is 6 . So for 6 the record should be

1

2

3

4

5

6

Can you please help me to get this.

Regards,

Mani

This post has been answered by Karthick2003 on Mar 28 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2014
Added on Mar 28 2014
11 comments
1,126 views