[MySQL] simple solution
\nselect \n\tstock_name,\n\tsum(case when operation=\'Buy\' then -price else price end) as capital_gain_loss\nfrom Stocks\ngroup by stock_name\n
```\nselect \n\tstock_name,\n\tsum(case when operation=\'Buy\' then -price else price end) as capital_gain_loss\nfrom Stocks\ngroup by stock_name\n```
[]