SELECT A.BUSINESS_UNIT , A.INV_ITEM_ID , A.DT_TIMESTAMP , A.CM_UNIT_COST FROM PS_CM_ACTUAL_COST A , PS_BU_ITEMS_INV B WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.INV_ITEM_ID = B.INV_ITEM_ID AND A.COST_ELEMENT = B.COST_ELEMENT AND A.DT_TIMESTAMP = ( SELECT MAX(C.DT_TIMESTAMP) FROM PS_CM_ACTUAL_COST C WHERE C.BUSINESS_UNIT = A.BUSINESS_UNIT AND C.INV_ITEM_ID = A.INV_ITEM_ID ) AND A.SEQ_NBR = ( SELECT MAX(D.SEQ_NBR) FROM PS_CM_ACTUAL_COST D WHERE D.BUSINESS_UNIT = A.BUSINESS_UNIT AND D.INV_ITEM_ID = A.INV_ITEM_ID AND D.DT_TIMESTAMP = A.DT_TIMESTAMP ) AND A.CM_SEQ_COST = ( SELECT MAX(E.CM_SEQ_COST) FROM PS_CM_ACTUAL_COST E WHERE E.BUSINESS_UNIT = A.BUSINESS_UNIT AND E.INV_ITEM_ID = A.INV_ITEM_ID AND E.DT_TIMESTAMP = A.DT_TIMESTAMP AND E.SEQ_NBR = A.SEQ_NBR)
|