SELECT A.BUSINESS_UNIT , A.INV_ITEM_ID , A.DT_TIMESTAMP , A.CM_UNIT_COST FROM PS_CM_PERPAVG_COST A , PS_BU_ITEMS_INV B , PS_CM_ITEM_LED_VW C WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.INV_ITEM_ID = B.INV_ITEM_ID AND A.COST_ELEMENT = B.COST_ELEMENT AND B.BUSINESS_UNIT = C.BUSINESS_UNIT AND B.INV_ITEM_ID = C.INV_ITEM_ID AND A.CM_BOOK = C.CM_BOOK AND C.DEFAULT_LEDGER_GRP = 'Y' AND C.PRIMARY_LEDGER = 'Y' AND A.DT_TIMESTAMP = ( SELECT MAX(D.DT_TIMESTAMP) FROM PS_CM_PERPAVG_COST D WHERE D.BUSINESS_UNIT = A.BUSINESS_UNIT AND D.INV_ITEM_ID = A.INV_ITEM_ID AND D.CM_BOOK = A.CM_BOOK) AND A.SEQ_NBR = ( SELECT MAX(P.SEQ_NBR) FROM PS_CM_PERPAVG_COST P WHERE P.BUSINESS_UNIT = A.BUSINESS_UNIT AND P.INV_ITEM_ID = A.INV_ITEM_ID AND P.CM_BOOK = A.CM_BOOK AND P.DT_TIMESTAMP = A.DT_TIMESTAMP )
|