Easy to understand | MySQL Solution
```\nSELECT stock_name, SUM(IF(operation = \'buy\', -price, price)) AS capital_gain_loss \nFROM Stocks \nGROUP BY stock_name;
```\nSELECT stock_name, SUM(IF(operation = \'buy\', -price, price)) AS capital_gain_loss \nFROM Stocks \nGROUP BY stock_name;
['MySQL']