Dear All, I am having trouble coding the average pricing of stock. Data FLAG QTY PRICE AVG_PRICE CALCULATION Buy 50 100 Buy 50 101 Buy 50 102 Sell 100 101.5 101 (50*100+50*101+50*102)/150 Buy 50 99 Sell 50 99.5 100.5 (50*100+50*101+50*102+50*99)/(150+50) I need to generate weighted average price against flag 'S' as shown above with calculation how to calculate avg_price. In case of first sell,I need weighted average price of all buys. total quantity purchased before first sell is 150 and quantity sold is 100. Balance quanity is 50. To generate price against second 'Sell' we nee to take average of first 3 buys and 4th buy. Kindly help me out. Regards Sandeep Gupta
... View more