89%
\n\n# Code\n\n# Write your MySQL query statement below\nSELECT p.product_id, ROUND(ifnull(SUM(p.price * u.units)/SUM(u.units), 0), 2) as average_price\nFROM Pri
\n\n# Code\n```\n# Write your MySQL query statement below\nSELECT p.product_id, ROUND(ifnull(SUM(p.price * u.units)/SUM(u.units), 0), 2) as average_price\nFROM Prices p\nLEFT JOIN UnitsSold u\nON p.product_id = u.product_id and p.start_date <= u.purchase_date and u.purchase_date <= p.end_date  \nGROUP BY p.product_id\nHAVING SUM(u.units) and SUM(p.price) or average_price = 0\n \n```
['MySQL']