Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Fetching latest transaction from MTL_MATERIAL_TRANSACTIONS.

user533671Apr 29 2014 — edited Apr 30 2014

Hi Friends

Please let me know  how to fetch latest transaction for the particular item for a particular transaction date..

i have the record like this.

TRANSACTION_ID
TRANSACTION_DATE
TRANSACTION_QUANTITY
LAST_UPDATE_DATE
INVENTORY_ITEM_ID
ORIGINAL_TRANSACTION_TEMP_ID
Header 7Header 8
294620363
4/29/2014 11:44
-8.085
4/29/2014 13:07
185140
294620353
294620339
4/29/2014 11:44
-7.085
4/29/2014 12:39
185140
294620330
294620158
4/29/2014 11:44
-6.085
4/29/2014 11:46
185140
294620276
4/29/2014 11:44
-12.17
4/29/2014 11:49
185140
294620204
4/29/2014 11:46
-6.085
4/29/2014 11:46
185140

Org id , subinventory code everything same for all records.

i need 1st, 4th, 5 th row to be displayed. for 1 item , i have 3 (3rd, 4th, 5th row) transactions.

when i updated the 3rd row , 2 row created.

when i updated the 2row, 1st row creaated. So , latest transaction is 1st row. i need 1st, 4th, 5 th row to be displayed. Is there any function or package to display latest transaction of the particular transaction or any other way to fetch those records..

i used the below query. it is not coming correctly.

select mmt.actual_cost, inventory_item_id, mmt.transaction_date , mmt.transaction_quantity ,mmt.* from mtl_material_transactions mmt

where inventory_item_id = 185140

and trunc(transaction_date) = '29-APR-2014'

and transaction_type_id = 35   

         AND transaction_id in

          (SELECT MAX (transaction_id)

             FROM apps.mtl_material_transactions mmt1

            WHERE TRUNC (mmt1.transaction_date) = '29-APR-2014' --TRUNC (:tnpl_correct_header.transaction_date)

              AND mmt1.inventory_item_id = mmt.inventory_item_id

              and mmt1.transaction_date = mmt.transaction_date

              group by transaction_date)             

order by mmt.transaction_date asc , mmt.transaction_id desc   

Please help me.

Thanks in advance.

Mano

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 28 2014
Added on Apr 29 2014
7 comments
1,636 views