Super Logic with sum and group by
\n\nselect stock_name,sum(if(operation=\'Sell\',price,-price)) as capital_gain_loss\nfrom stocks\ngroup by stock_name\n\n# please upvote me it would encourage m
\n```\nselect stock_name,sum(if(operation=\'Sell\',price,-price)) as capital_gain_loss\nfrom stocks\ngroup by stock_name\n```\n# please upvote me it would encourage me alot\n
['MySQL']