| SQL✅ | LEFT JOIN🤩| Easy Approach🔥| TOP 2023🔝 |
Hello LeetCode fans,\n\nBelow I presented a solution to the problem (1251. Average Selling Price).\nIf you found it useful or informative,\nClick the "upvote" b
# Hello LeetCode fans,\n\nBelow I presented a solution to the problem (1251. Average Selling Price).\nIf you found it `useful` or `informative`,\nClick the "`upvote`" button below and it means I was able to help someone.\nYour upvotes encourage me and others who are `working hard` to improve their problem solving skills.\n# Code\n```\nSELECT p.product_id, IFNULL(ROUND(SUM(units*price)/SUM(units),2),0) AS average_price\n FROM Prices p LEFT JOIN UnitsSold u\n  ON p.product_id = u.product_id AND\n    u.purchase_date BETWEEN start_date AND end_date\n      group by product_id\n\n\n\n```
['MySQL']