MSSQL answer
```\n\n\n    SELECT A.product_id, \n           ROUND(CAST(SUM(A.units*B.price) AS FLOAT)/SUM(A.units),2)  AS average_price\n    FROM   UnitsSold  AS A \n    INN
```\n\n\n    SELECT A.product_id, \n           ROUND(CAST(SUM(A.units*B.price) AS FLOAT)/SUM(A.units),2)  AS average_price\n    FROM   UnitsSold  AS A \n    INNER JOIN Prices AS B ON A.product_id = B.product_id \n                          AND A.purchase_date BETWEEN B.start_date AND B.end_Date\n    GROUP BY A.product_id\n
['MS SQL Server']