Faster than 81 % | Easy to Understand | MYSQL
\nselect \n\tp.product_id, \n\tround(sum(u.units*p.price)/sum(u.units), 2)  as average_price \nfrom prices as p join unitssold as u \n\twhere \n\t\tu.product_id
```\nselect \n\tp.product_id, \n\tround(sum(u.units*p.price)/sum(u.units), 2)  as average_price \nfrom prices as p join unitssold as u \n\twhere \n\t\tu.product_id = p.product_id and \n\t\tu.purchase_date <= p.end_date and \n\t\tu.purchase_date >= p.start_date \n\tgroup by p.product_id;\n```\n\n**I hope that you\'ve found it useful.**\n*In that case, please do upvote*
['MySQL']