Simple MySQL solution
\nselect p.product_id, ifnull(round(sum(p.price*u.units)/sum(u.units),2),0) as average_price\nfrom Prices as p left join UnitsSold as u on p.product_id = u.prod
```\nselect p.product_id, ifnull(round(sum(p.price*u.units)/sum(u.units),2),0) as average_price\nfrom Prices as p left join UnitsSold as u on p.product_id = u.product_id and u.purchase_date between p.start_date and p.end_date group by p.product_id; \n```
[]