Can someone help me with the this?
This is my table structure:
rec_id product_id quantity quantity_in quantity_out balance stock_date status 1 2 342 NULL 17 325 2009-10-23 1 2 2 325 NULL 124 201 2009-10-23 1 3 1 156 NULL 45 111 2009-10-23 1 4 2 201 NULL 200 1 2009-10-23 1 5 2 1 NULL 1 0 2009-10-23 1 6 1 111 NULL 35 76 2009-10-23 1
All I want is the last transaction done for a given product: product_id, quantity, quantity_out and balance from this table.
Example, there are 2 transaction done for product 2 (ids 1 & 2):
final balance for product_id 2 is 0 -> stored in rec_id 5
final balance for product_id 1 is 76 -> stored in rec_id 6
Final Result/Output should be like this:
recid productid quantity quantityin quantityout balance stock_date status 5 2 1 NULL 1 0 2009-10-23 1 6 1 111 NULL 35 76 2009-10-23 1
Thanks