Simple solution with decode function instead of "case when"
Intuition\n Describe your first thoughts on how to solve this problem. \nGood way is solve with "case when", but better way is by DECODE function.\n# Approach\n
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGood way is solve with "case when", but better way is by DECODE function.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/* Write your PL/SQL query statement below */\n\nselect \ns.stock_name, \nsum(decode(s.operation, \'Sell\', s.price, -s.price)) capital_gain_loss \nfrom Stocks s\ngroup by s.stock_name\n```
['Oracle']