P&L on Stock Trades
For each stock compute its capital gain or loss: total sales minus total purchases. Return stock_name and capital_gain_loss.
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.
| stock_name | capital_gain_loss |
|---|---|
| MSFT | 30 |
| GOOG | 20 |
| AAPL | 40 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in