UPDATE Base_ProductInfo
SET Base_ProductInfo.AvgPrice=a.AvgPrice
FROM Base_ProductInfo
INNER JOIN (SELECT (SUM(Base_ProductInfo_Storage.stockMoney)/SUM(Base_ProductInfo_Storage.Product_Storage))AS AvgPrice,Product_Id
FROM Base_ProductInfo_Storage
GROUP BY Product_Id having(SUM(Base_ProductInfo_Storage.stockMoney)>0 and SUM(Base_ProductInfo_Storage.Product_Storage)>0 )) AS a ON dbo.Base_ProductInfo.Product_Id=a.Product_Id
SET Base_ProductInfo.AvgPrice=a.AvgPrice
FROM Base_ProductInfo
INNER JOIN (SELECT (SUM(Base_ProductInfo_Storage.stockMoney)/SUM(Base_ProductInfo_Storage.Product_Storage))AS AvgPrice,Product_Id
FROM Base_ProductInfo_Storage
GROUP BY Product_Id having(SUM(Base_ProductInfo_Storage.stockMoney)>0 and SUM(Base_ProductInfo_Storage.Product_Storage)>0 )) AS a ON dbo.Base_ProductInfo.Product_Id=a.Product_Id
UPDATE a
SET AvgPrice=b.AvgPrice
FROM Base_ProductInfo a
INNER JOIN (SELECT (SUM(stockMoney)/SUM(Product_Storage))AS AvgPrice,Product_Id
FROM Base_ProductInfo_Storage
GROUP BY Product_Id having(SUM(stockMoney)>0 and SUM(Product_Storage)>0 )) AS b ON a.Product_Id=b.Product_Id