MySQL Solution
Code\n\n# Write your MySQL query statement below\nselect stock_name, sum(if(operation="Buy", -price, price)) as capital_gain_loss\nfrom Stocks group by stock_na
# Code\n```\n# Write your MySQL query statement below\nselect stock_name, sum(if(operation="Buy", -price, price)) as capital_gain_loss\nfrom Stocks group by stock_name;\n```
['MySQL']