Simple and concise MySQL solution beats 100%
\n# Write your MySQL query statement below\nSELECT a.product_id,IFNULL(ROUND(SUM(b.units*a.price)/SUM(b.units),2),0) as average_price\nFROM Prices as a\nLEFT JO
```\n# Write your MySQL query statement below\nSELECT a.product_id,IFNULL(ROUND(SUM(b.units*a.price)/SUM(b.units),2),0) as average_price\nFROM Prices as a\nLEFT JOIN UnitsSold as b\nON a.product_id=b.product_id AND (b.purchase_date BETWEEN a.start_date AND a.end_date)\nGROUP BY product_id;\n```
[]