Simple MySQL Solution | Faster than 100% | Easy to understand
\nselect prices.product_id, ROUND(SUM(price * units) / SUM(units), 2) as average_price\nfrom Prices join UnitsSold \non prices.product_id = unitssold.product_id
```\nselect prices.product_id, ROUND(SUM(price * units) / SUM(units), 2) as average_price\nfrom Prices join UnitsSold \non prices.product_id = unitssold.product_id\nand purchase_date between start_date and end_date\ngroup by product_id\n\n# Do upvote if you like the solution.\n```
['MySQL']