Question : Oracle -- SQL Join Statements

How can I change the below SQL so results
display like the attached 1.jpg, showing
both received and non-received purchase
orders ?

select polt.order_no PO_NUMBER,
       polt.line_no,
       polt.original_qty ORD_QTY
       -- RED commented out -- , sum(prt.qty_arrived) ARRIVED
from purchase_order_line_tab polt
inner join purchase_order_tab pot
on pot.order_no = polt.order_no
left outer join PURCHASE_RECEIPT_TAB prt
on prt.order_no = pot.order_no
where polt.order_no in ('28','29')
  and pot.rowstate <> 'Planned'
-- RED commented out -- and prt.rowstate <> 'Cancelled'
-- RED commented out -- and polt.line_no = prt.line_no
GROUP BY polt.order_no, polt.line_no, polt.original_qty
Attachments:
 
1
1
 

Answer : Oracle -- SQL Join Statements

I am pretty sure this one is actually correct, but without a test case with all 3 tables, I'm not sure.  The test I used is probably close, so it should work.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
select polt.order_no PO_NUMBER, 
       polt.line_no,
       polt.original_qty ORD_QTY,
       sum(prt.qty_arrived) ARRIVED
from purchase_order_line_tab polt
inner join purchase_order_tab pot
on pot.order_no = polt.order_no
left outer join PURCHASE_RECEIPT_TAB prt
on (prt.order_no = pot.order_no and polt.line_no = prt.line_no)
where polt.order_no in ('28','29')
  and pot.rowstate <> 'Planned'
  and NVL(prt.rowstate, 'NC') <> 'Cancelled'
GROUP BY polt.order_no, polt.line_no, polt.original_qty;
Random Solutions  
 
programming4us programming4us