Fast MySQL Solution (Top 95%)
\n\nselect stock_name, sum(case when operation = \'Sell\' then price \n                      else -price end) capital_gain_loss\nfrom Stocks\ngroup by stock_nam
![image](https://assets.leetcode.com/users/images/1be1055a-7eb4-43ee-9b54-000396bcc031_1669723952.357253.png)\n```\nselect stock_name, sum(case when operation = \'Sell\' then price \n                      else -price end) capital_gain_loss\nfrom Stocks\ngroup by stock_name\n```\n\nThis solution works in oracle as well
['MySQL']