SOLUTION: 85% Faster
SELECT stock_name, SUM(CASE\n                      WHEN operation = "Buy" THEN -(price)\n                      WHEN operation = "Sell" THEN (price)\n           
SELECT stock_name, SUM(CASE\n                      WHEN operation = "Buy" THEN -(price)\n                      WHEN operation = "Sell" THEN (price)\n                      END ) AS capital_gain_loss\nFROM Stocks\nGROUP BY stock_name\nOrder By capital_gain_loss DESC;
[]