SELECT
	w.record_number
	,w.Name
	,IF(w.record_number = 1, si.Street,w.Street) AS Street
	,IF(w.record_number = 1, si.City,w.City) AS City
	,s.Name AS State
	,IF(w.record_number = 1, si.Postal_Code, w.Postal_Code) AS Postal_Code
	,c.Alpha_3 AS Country
	,SUM(pw.Stock) AS Total_Stock
	,SUM(IF(p.Package_Weight > 0 AND p.Ship_Separately = 1, p.Package_Weight, p.Weight) * pw.Stock) AS Stock_Weight
	,SUM(p.Base_Price * pw.Stock) AS Stock_Retail_Value
FROM
	Locations w

LEFT JOIN
	Store_Information si
ON
	w.record_number = si.record_number

LEFT JOIN
	REL_Products__Warehouses pw
ON
	w.record_number = pw.Warehouses_rn

LEFT JOIN
	States s
ON
	w.State_or_Province = s.record_number
	OR si.State_or_Province = s.record_number

LEFT JOIN
	Countries c
ON
	w.Country = c.record_number
	OR si.Country = c.record_number

LEFT JOIN
	Products p
ON
	pw.Products_rn = p.record_number