Easy MySQL JOIN Solution
\n# Code\nmysql []\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\nF
\n# Code\n```mysql []\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 LEFT JOIN UNITSSOLD U ON P.PRODUCT_ID = U.PRODUCT_ID\nAND U.PURCHASE_DATE >= P.START_DATE AND U.PURCHASE_DATE <= P.END_DATE\nGROUP BY P.PRODUCT_ID;\n\n```
['MySQL']