menu
You can perform multiplication using the method SUM and get decimals complementing with numeric in the following way:

Example:
select 
  us.product_id,
  ROUND(SUM(us.units * p.price)::numeric / SUM(us.units), 2) AS average_price 
from Prices p
left join UnitsSold us on us.product_id = p.product_id and us.purchase_date between p.start_date and p.end_date
group by us.product_id
order by us.product_id