The goal of this query is to update the columns MinPrice and MaxPrice in Table 1 with Max and Min prices from Table2 where CountryCode and ProductCode are matching.
When I run this query the whole columns of Max and Minprice in Table 1 fill with the first value that comes up from the select query.
If I run the select query by itself it shows the correct min and max values per Country per Product.
UPDATE Table1 SET MinPrice = MinOfPrice, Maxprice = MaxOfPrice FROM (SELECT Min(lp.Price) AS MinOfPrice, Max(lp.Price) AS MaxOfPrice FROM Table2 lp INNER JOIN Table1 d ON lp.CountryCode = d.CountryCode AND lp.ProductCode = d.ProductCode GROUP BY lp.CountryCode, lp.ProductCode, lp.PriceOriginTypeCode) h ;