Hi Experts,
I have two tables one "Sales Table - SALES_TABLE01" and another "Inventory Table - INVENTORY_TABLE02" now I want to merge two tables, Logic is to add sales & margin item-wise & month-wise and extract last transaction itemwise & month-wise from Inventory table.
Now my question is : How I will join two tables so at a same time I am adding sales, margin itemwise & monthwise and extracting LAST transaction itemwise & monthwise "ON HAND BALANCE" from Inventory table.
If there is any other way around please let me know.
SALES_TABLE01
ITEM NO TRAN DT SALES MARGIN
001 01-APR-2003 1000.00 250.00
001 05-APR-2003 2000.00 500.00
001 07-MAY-2003 3000.00 750.00
001 10-MAY-2003 1000.00 250.00
001 12-MAY-2003 1000.00 250.00
002 01-APR-2003 1000.00 100.00
002 15-APR-2003 1500.00 100.00
INVENTORY_TABLE02
ITEM NO TRAN DT ON HAND BALANCE
001 01-APR-2003 15
001 05-APR-2003 20
001 07-APR-2003 10
001 15-APR-2003 25
001 05-MAY-2003 100
001 18-MAY-2003 60
002 01-APR-2003 150
002 15-APR-2003 600
OUTPUT_TABLE03
ITEM NO MONTH SALES MARGIN INVENTORY
001 APR 3000.00 750.00 25
001 MAY 2000.00 1250.00 60
002 APR 2500.00 200.00 600
I have two tables one "Sales Table - SALES_TABLE01" and another "Inventory Table - INVENTORY_TABLE02" now I want to merge two tables, Logic is to add sales & margin item-wise & month-wise and extract last transaction itemwise & month-wise from Inventory table.
Now my question is : How I will join two tables so at a same time I am adding sales, margin itemwise & monthwise and extracting LAST transaction itemwise & monthwise "ON HAND BALANCE" from Inventory table.
If there is any other way around please let me know.
SALES_TABLE01
ITEM NO TRAN DT SALES MARGIN
001 01-APR-2003 1000.00 250.00
001 05-APR-2003 2000.00 500.00
001 07-MAY-2003 3000.00 750.00
001 10-MAY-2003 1000.00 250.00
001 12-MAY-2003 1000.00 250.00
002 01-APR-2003 1000.00 100.00
002 15-APR-2003 1500.00 100.00
INVENTORY_TABLE02
ITEM NO TRAN DT ON HAND BALANCE
001 01-APR-2003 15
001 05-APR-2003 20
001 07-APR-2003 10
001 15-APR-2003 25
001 05-MAY-2003 100
001 18-MAY-2003 60
002 01-APR-2003 150
002 15-APR-2003 600
OUTPUT_TABLE03
ITEM NO MONTH SALES MARGIN INVENTORY
001 APR 3000.00 750.00 25
001 MAY 2000.00 1250.00 60
002 APR 2500.00 200.00 600