Round || Sum || Left Join
Intuition\n Describe your first thoughts on how to solve this problem. \n\nSimple join and basic maths\n\n# Code\n\n# Write your MySQL query statement below\n\n
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nSimple join and basic maths\n\n# Code\n```\n# Write your MySQL query statement below\n\nselect p.product_id,round(sum(p.price*u.units)/sum(u.units),2) as average_price \nfrom Prices p \nleft join \nUnitsSold u \non p.product_id=u.product_id \nwhere u.purchase_date>=p.start_date and u.purchase_date<=p.end_date \ngroup by product_id;\n```
['MySQL']