Simple MYSQL Solution
\n\nselect \n\t\tp.product_id ,\n\t\tROUND((SUM(u.units*p.price)/SUM(units)),2) average_price \n\nfrom Prices p , UnitsSold u \nwhere \n\t\tp.product_id = u.pro
```\n\nselect \n\t\tp.product_id ,\n\t\tROUND((SUM(u.units*p.price)/SUM(units)),2) average_price \n\nfrom Prices p , UnitsSold u \nwhere \n\t\tp.product_id = u.product_id \n\t\tand u.purchase_date between p.start_date and p.end_date \n\t\t\ngroup by p.product_id\n\n```
[]