[MySQL] SUM(IF())
\n\nSELECT \n    stock_name, \n    SUM(IF(operation = "Sell", price, -price)) AS capital_gain_loss\nFROM Stocks\nGROUP BY stock_name\n
\n```\nSELECT \n    stock_name, \n    SUM(IF(operation = "Sell", price, -price)) AS capital_gain_loss\nFROM Stocks\nGROUP BY stock_name\n```
['MySQL']