Simple Solution in MySQL👽💯
Intuition\n- MySQL\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n- Easy Approach\n Describe your approach to solving the problem.
# Intuition\n- MySQL\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n- Easy 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```\nselect \np.product_id,\nifnull(round(sum(units * price) / sum(units),2),0) as average_price\nfrom\nPrices p left join UnitsSold u\non p.product_id = u.product_id and u.purchase_date between start_date and end_date\ngroup by product_id;\n```
['MySQL']