You are analyzing a fintech database for stock market activity. Each record is either a Buy or a Sell transaction.
Write an SQL query to report the Capital Gain/Loss for each user.
| user_id(INTEGER) | operation(VARCHAR) | operation_day(INTEGER) | price(INTEGER) |
|---|---|---|---|
| 1 | Buy | 1 | 1000 |
| 1 | Sell | 5 | 1500 |
| 2 | Buy | 1 | 7000 |
| 2 | Sell | 10 | 1000 |
| 1 | Buy | 12 | 3000 |
| 1 | Sell | 15 | 3500 |
| user_id(INTEGER) | username(VARCHAR) |
|---|---|
| 1 | Trader_Alpha |
| 2 | Trader_Beta |
| transaction_id(INTEGER) | user_id(INTEGER) | verified(BOOLEAN) |
|---|---|---|
| 99 | 1 | true |
| user_id(INTEGER) | capital_gain_loss(INTEGER) |
|---|---|
| 1 | 1000 |
| 2 | -6000 |