easy MySQL
\nselect p.product_id,  round(sum(price * units) / sum(units), 2) as average_price \nfrom prices p\nleft join unitssold u\non p.product_id = u.product_id and pu
```\nselect p.product_id,  round(sum(price * units) / sum(units), 2) as average_price \nfrom prices p\nleft join unitssold u\non p.product_id = u.product_id and purchase_date between start_date and end_date\ngroup by product_id\n```
[]