MySQL Query using CASE statement
\nSELECT stock_name,\n       SUM(CASE WHEN operation = "Sell" THEN price ELSE 0 END) - SUM(CASE WHEN operation = "Buy" THEN price ELSE 0 END) AS capital_gain_lo
```\nSELECT stock_name,\n       SUM(CASE WHEN operation = "Sell" THEN price ELSE 0 END) - SUM(CASE WHEN operation = "Buy" THEN price ELSE 0 END) AS capital_gain_loss\nFROM Stocks\nGROUP BY stock_name;\n```
[]