 Validation en grandes masses sur les polluants de l'interface d'extraction uniquement 
 NOx 38, PM10 65, PM2.5 108, COV 129, SO2 48, NH3 36, consommations 131
 
-select an, id_polluant, val_orig, val_secten1
+select an, id_polluant, val_orig, val_tmp, val_secten1
 from (
+	-- Table source
 	select an, id_polluant, sum(val) as val_orig
 	from total.bilan_comm_v4
 	where id_polluant in (38, 65, 108, 16, 48, 36, 131)


-- 	union all

-- 	-- Slection des tablissements tertiaire dont on connait l'id (!= -999)
-- 	select distinct an, a.id_comm, b.code_gerep, id_snap3, id_energie from total_ter.bilan_comm_v5_2015 as a left join src_ind.def_corresp_sources as b using (id_corresp) where id_corresp <> -999 and an = 2015 and (b.actif is true or b.actif is null) and (b.id_version_corresp = 5 or b.id_version_corresp is null)
-- 	union all
-- 	select distinct an, a.id_comm, b.code_gerep, id_snap3, id_energie from total_ter.bilan_comm_v5_2014 as a left join src_ind.def_corresp_sources as b using (id_corresp) where id_corresp <> -999 and an = 2014 and (b.actif is true or b.actif is null) and (b.id_version_corresp = 5 or b.id_version_corresp is null)

;
	
/**
Jointure du nombre d'établissements
*/
alter table total.bilan_comm_v4_secten1 drop column if exists ss_nb_etab;
alter table total.bilan_comm_v4_secten1 add column ss_nb_etab double precision;
