 FROM
 ( 
 	SELECT 
-	sum(sector_area_retail), 
+	sum(coalesce(sector_area_retail,0)), 
 	substr(nuts,1,5) 
 	FROM calc_ego_loads.ego_deu_load_area
 	GROUP BY substr(nuts,1,5)

FROM
( 
	SELECT 
	sum(sector_area_agricultural), 
	substr(nuts,1,5) 
	FROM calc_ego_loads.ego_deu_load_area
	GROUP BY substr(nuts,1,5)

) AS sub
WHERE
sub.id = a.id;

-- Add Geometry information to consumption table

ALTER TABLE calc_ego_loads.ego_deu_consumption
ADD COLUMN geom geometry (Polygon,3035); 

UPDATE calc_ego_loads.ego_deu_consumption a
SET geom = b.geom
FROM calc_ego_loads.ego_deu_load_area b
WHERE a.id = b.id;


---------- ---------- ----------
