EASIEST SOLUTION WITH EXPLANATION 98% BEATS ON RUNTIME - MYSQL SOLUTION
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\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- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n# Write your MySQL query statement below\nSELECT p.product_id, IFNULL(ROUND(SUM(units*price)/SUM(units),2),0) AS average_price\nFROM Prices p LEFT JOIN UnitsSold u\nON p.product_id = u.product_id AND\nu.purchase_date BETWEEN start_date AND end_date\ngroup by product_id\n```
['MySQL']