using if ✅✅✅✅✅✅✅✅
upvote \n\n\nselect stock_name, sum(if(operation = "Buy",-price,price)) as capital_gain_loss from stocks\ngroup by stock_name;\n
# upvote \n\n```\nselect stock_name, sum(if(operation = "Buy",-price,price)) as capital_gain_loss from stocks\ngroup by stock_name;\n```
[]