[MYSQL] join and aggregation
\nselect us.product_id,round(sum(units * price) / sum(units), 2) as average_price\nfrom unitssold us\njoin prices p\non us.product_id = p.product_id and us.purc
```\nselect us.product_id,round(sum(units * price) / sum(units), 2) as average_price\nfrom unitssold us\njoin prices p\non us.product_id = p.product_id and us.purchase_date between p.start_date and p.end_date\ngroup by 1\n```
[]