Need to calculate a stock market portfolio based on trades in a database. The calculation I'm looking to do via SQL are average price, rate of return, portfolio value, etc.
Sample data:
Stock Shares Price Value A 100 50 5000 A -20 60 -1200 A 50 40 2000
I haven't been able to do it with SQL, so I'm guess I may need to script the output, so any help there appreciated.