MySQL | Easy solution
\n\n# Code\n\n# Write your MySQL query statement below\nSELECT p.product_id, ifnull(round(sum(price*units)/sum(units),2),0) AS average_price\nFROM Prices p LEFT
\n\n# Code\n```\n# Write your MySQL query statement below\nSELECT p.product_id, ifnull(round(sum(price*units)/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']