[ MYSQL ] ✅✅ Simple MYSQL Solution Using SUM | Group By | IF and ELSE Condition🥳✌👍
If You like the Solution, Don\'t Forget To UpVote Me, Please UpVote! \uD83D\uDD3C\uD83D\uDE4F\n# Runtime: 1011 ms, faster than 13.16% of MySQL online submission
# If You like the Solution, Don\'t Forget To UpVote Me, Please UpVote! \uD83D\uDD3C\uD83D\uDE4F\n# Runtime: 1011 ms, faster than 13.16% of MySQL online submissions for Capital Gain/Loss.\n# Memory Usage: 0B, less than 100.00% of MySQL online submissions for Capital Gain/Loss.\n\n\tSELECT STOCK_NAME,\n\tSUM( CASE WHEN operation = \'Sell\' THEN PRICE ELSE 0 END)-\n\tSUM( CASE WHEN operation = \'Buy\' THEN PRICE ELSE 0 END)\n\tAS \'capital_gain_loss\'\n\tFROM STOCKS\n\tGROUP BY STOCK_NAME
['MySQL']