You are on page 1of 1

select round(nvl(sum(UNIT_COST), 0), 5) last_item_c

from cst_layer_costs clc -- cst_perpavg_cost


where clc.inventory_item_id = Q_ITEM.inventory_item_id
and clc.TRANSACTION_COST_ID != 0
and clc.transaction_id =
(select max(distinct bb.transaction_id)
from cst_layer_costs bb
where bb.TRANSACTION_COST_ID != 0
and bb.inventory_item_id = Q_ITEM.inventory_item_id
and bb.cost_date =
(select max(distinct bbb.cost_date)
from cst_layer_costs bbb
where bbb.TRANSACTION_COST_ID != 0
and bbb.inventory_item_id = Q_ITEM.inventory_item_id))

with et as (select distinct esi.inventory_item_id, esi.item_number AS item_code


from fusion.egp_system_items_b esi
where esi.item_number= <item>
)
select *
from fusion.CST_PERPAVG_COST a,
et b
where a.inventory_ITEM_id = b.inventory_item_id
order by CREATION_DATE

You might also like