SQL ✅ | ROUND, SUM, GROUP BY ✅✅ | Easy to understand
\n\n\n# Code\n\nselect \np.product_id,\nround(sum(p.price *  u.units) / sum(u.units),2) as average_price  \nfrom Prices p join UnitsSold u \n        on p.produc
![image.png](https://assets.leetcode.com/users/images/70b32547-5da1-4c00-a75b-487c26841b86_1686130124.8750567.png)\n\n\n# Code\n```\nselect \np.product_id,\nround(sum(p.price *  u.units) / sum(u.units),2) as average_price  \nfrom Prices p join UnitsSold u \n        on p.product_id = u.product_id and p.start_date <= u.purchase_date and u.purchase_date <= p.end_date\ngroup by p.product_id\n\n```
['Database', 'MySQL']