NULL Test Case
Intuition\nWhile Filtering using where clause make sure you include the OR Clause to include NULL value rows on table join. See the code\n\n# Approach\n Describ
# Intuition\nWhile Filtering using where clause make sure you include the OR Clause to include NULL value rows on table join. See the code\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nSELECT t1.product_id  , IFNULL(ROUND(SUM((t1.price * t2.Units))/SUM(t2.Units),2),0) AS \'average_price\'\nFROM Prices t1\nLEFT JOIN UnitsSold t2\nON t1.product_id = t2.product_id\nWHERE t2.purchase_date BETWEEN t1.start_date AND t1.end_date OR t2.purchase_date is NULL\nGROUP BY t1.product_id\n\n\n\n\n```
['MySQL']