MySQL Solution- the easiest
```\nselect \nu.product_id, \nround(sum(u.units * p.price) / sum(u.units), 2) as average_price from \nprices p \njoin unitssold u \non p.product_id = u.product_
```\nselect \nu.product_id, \nround(sum(u.units * p.price) / sum(u.units), 2) as average_price from \nprices p \njoin unitssold u \non p.product_id = u.product_id \nand u.purchase_date between p.start_date and p.end_date\ngroup by \nu.product_id
[]