Oracle SQL | Easy Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\nMake sure to use NVL so that if no units are sold for a product 0 should be display
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\nMake sure to use NVL so that if no units are sold for a product 0 should be displayed and use LEFT JOIN instead of INNER JOIN.\n\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\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\n/* Write your PL/SQL query statement below */\nselect p.product_id, NVL(round(sum(price*units)/sum(units),2),0) as average_price\nfrom prices p\nleft join unitssold u\non p.product_id=u.product_id  \n    and u.purchase_Date between p.start_date and p.end_Date\ngroup by p.product_id;\n\n```
['Oracle']