MySQL || SOLUTION
\nSELECT \n    summed.stock_name,\n    SUM(summed.price) AS capital_gain_loss\nFROM (\n    SELECT \n        stock_name,\n        CASE\n            WHEN operatio
```\nSELECT \n    summed.stock_name,\n    SUM(summed.price) AS capital_gain_loss\nFROM (\n    SELECT \n        stock_name,\n        CASE\n            WHEN operation = \'Buy\' THEN -price\n            WHEN operation = \'Sell\' THEN price\n        END as price\n    FROM Stocks\n) AS summed\nGROUP BY summed.stock_name\n```
['MySQL']