I have 4 queries and need to amalgamate them to create one set of results.
The first:
This is the primary query which should use the other two to obtain an additional column of cost.
I need to add
To get the cost I need to go to the transaction history table:
and this gives me the purchase order line, from where the cost is held:
But if there is no transaction history record that matches the criteria OR no purchase order line, then it needs to use the standard cost:
I am really struggling - any offers please?
Applications Support
UK
The first:
Code:
select
ipis.part_no, ipis.contract, ipis.lot_batch_no, ipis.serial_no, ipis.qty_onhand
from
ifsapp.inventory_part_in_stock_tab ipis
where
ipis.qty_onhand > 0
This is the primary query which should use the other two to obtain an additional column of cost.
I need to add
Code:
ipis.qty_onhand, cost
To get the cost I need to go to the transaction history table:
Code:
select
ith.order_no, ith.release_no, ith.sequence_no, ith.line_item_no
from
ifsapp.inventory_transaction_hist_tab ith
where
ith.transaction_code in ('NREC','ARRIVAL') and
ith.order_type='PUR ORDER' and
ith.part_no = ipis.part_no and
ith.contract = ipis.contract and
ith.lot_batch_no = ipis.lot_batch_no and
ith.serial_no = ipis.serial_no
and this gives me the purchase order line, from where the cost is held:
Code:
select
pol.buy_unit_price
from
ifsapp.purchase_order_line_tab pol
where
pol.order_no=ith.order_no and
pol.line_no=ith.line_line_no
But if there is no transaction history record that matches the criteria OR no purchase order line, then it needs to use the standard cost:
Code:
select
ip.standard_cost
from
ifsapp.inventory_part ip
where
ip.part_no = ipis.part_no and
ip.contract = ipis.contract
I am really struggling - any offers please?
Applications Support
UK