Beats 98.22% of users with MySQL JOIN ✅ 100% EASY || FAST 🔥|| CLEAN SOLUTION 🌟
\n\n# Code\n\n# Write your MySQL query statement below\nSELECT p.product_id, IFNULL(ROUND(SUM(p.price*u.units)/SUM(u.units), 2), 0) as average_price\nFROM Price
\n\n# Code\n```\n# Write your MySQL query statement below\nSELECT p.product_id, IFNULL(ROUND(SUM(p.price*u.units)/SUM(u.units), 2), 0) as average_price\nFROM Prices p\nLEFT JOIN UnitsSold u\nON p.product_id = u.product_id\nand u.purchase_date >= p.start_date\nand u.purchase_date <= p.end_date\nGROUP BY p.product_id\n```
['MySQL']