ACCESS數據厙的:
select item_no,(today_hand+int_qty-out_qty)as on_hand_qty
(select k.*,b.outqty as OUT_QTY
from(select m.ITEM_NO,m.TODAY_HAND,a.intqty as INT_QTY
from inv_mast m
Left outer join (select item_no,sum(int_qty)as intqty from inv_int group by item_no) a
on m.item_no=a.item_no ) k
Left outer join (select item_no,sum(out_qty)as outqty from inv_out group by item_no) b
on k.item_no=b.item_no)
ORACLE數據厙的:
select item_no,(today_hand+int_qty-out_qty)as on_hand_qty
from(select m.ITEM_NO,m.TODAY_HAND,a.intqty as INT_QTY,b.outqty as OUT_QTY
from inv_mast m
Left outer join (select item_no,sum(int_qty)as intqty from inv_int group by item_no) a
on m.item_no=a.item_no
Left outer join (select item_no,sum(out_qty)as outqty from inv_out group by item_no) b
on m.item_no=b.item_no)