Easy for understand postgreSQL solution
Code\n\n-- Write your PostgreSQL query statement below\nSELECT Prices.product_id,\n        COALESCE(ROUND(SUM(units * price)::numeric / SUM(units), 2), 0) AS av
# Code\n```\n-- Write your PostgreSQL query statement below\nSELECT Prices.product_id,\n        COALESCE(ROUND(SUM(units * price)::numeric / SUM(units), 2), 0) AS average_price \nFROM Prices\nLEFT JOIN UnitsSold ON UnitsSold.product_id = Prices.product_id AND purchase_date BETWEEN start_date AND end_date\nGROUP BY (Prices.product_id)\n```
['PostgreSQL']