Easy SQL using Sum and Group by
\n\n# Code\n\n# Write your MySQL query statement below\nSELECT stock_name , SUM(IF(operation = \'buy\',-price,price)) \nAS capital_gain_loss FROM Stocks GROUP B
\n\n# Code\n```\n# Write your MySQL query statement below\nSELECT stock_name , SUM(IF(operation = \'buy\',-price,price)) \nAS capital_gain_loss FROM Stocks GROUP BY stock_name;\n```
['MySQL']