Simple MySQL Solution, Beats 100%
\nSELECT\n    Prices.product_id,\n    ROUND(SUM(Prices.price * UnitsSold.units) / SUM(UnitsSold.units), 2) as average_price\nFROM\n    Prices\nINNER JOIN\n    U
```\nSELECT\n    Prices.product_id,\n    ROUND(SUM(Prices.price * UnitsSold.units) / SUM(UnitsSold.units), 2) as average_price\nFROM\n    Prices\nINNER JOIN\n    UnitsSold\nON\n    UnitsSold.purchase_date BETWEEN Prices.start_date AND Prices.end_date\n    AND\n    UnitsSold.product_id = Prices.product_id\nGROUP BY\n    Prices.product_id\n```
['MySQL']