[2026-08-14 08:34:21] local.DEBUG: FactureEnergetiqueQuery {"years":[2024],"filter_geo_ids":[-730258373],"top_n":10,"sql":"select \"result\".\"territoire_id\", COALESCE(t.name, '(non rattaché)') AS territoire, \"result\".\"year_id\", \"result\".\"id_type_comptable\", \"result\".\"rang\", \"result\".\"montant_euros\", \"result\".\"contribution\", CASE WHEN result.id_type_comptable = 1 THEN 'Dépenses' WHEN result.id_type_comptable = 2 THEN 'Recettes' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' END AS type_comptable, CASE WHEN result.rang = 0 AND result.id_type_comptable = 1 THEN 'Dépense totale' WHEN result.rang = 0 AND result.id_type_comptable = 2 THEN 'Recette totale' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' WHEN result.id_type_comptable = 1 THEN COALESCE(a.name, '') || ' - ' || COALESCE(fc.name, '') WHEN result.id_type_comptable = 2 THEN COALESCE(fdi.name, '') || ' - ' || COALESCE(v.name, '') END AS poste from ((select territoire_id, year_id, 1 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 1 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 2 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 2 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 3 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ABS(montant_euros) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\") union all (select fg.territoire_id, fg.year_id, 4 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ROUND((ABS(fg.montant_euros) / pa.population)::numeric, 2) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\" inner join (select \"dtm\".\"parent_id\" as \"territoire_id\", \"fp\".\"year_id\", SUM(fp.population) as population from \"observatoire\".\"fact_population\" as \"fp\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"fp\".\"geo_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"fp\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"fp\".\"year_id\") as \"pa\" on \"pa\".\"territoire_id\" = \"fg\".\"territoire_id\" and \"pa\".\"year_id\" = \"fg\".\"year_id\")) as \"result\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"result\".\"territoire_id\" left join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id\" = \"result\".\"poste_energetique_id\" left join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dpe\".\"activity_id\" left join \"observatoire\".\"dim_fuels\" as \"fc\" on \"fc\".\"id\" = \"dpe\".\"fuel_cat_id\" left join \"observatoire\".\"dim_filieres\" as \"fdi\" on \"fdi\".\"id\" = \"dpe\".\"filiere_detail_interne_id\" left join \"observatoire\".\"dim_vecteurs\" as \"v\" on \"v\".\"id\" = \"dpe\".\"vecteur_id\""} 
[2026-08-14 08:34:21] local.DEBUG: FactureEnergetiqueQuery {"years":[2024],"filter_geo_ids":[-730258373],"top_n":10,"sql":"select \"result\".\"territoire_id\", COALESCE(t.name, '(non rattaché)') AS territoire, \"result\".\"year_id\", \"result\".\"id_type_comptable\", \"result\".\"rang\", \"result\".\"montant_euros\", \"result\".\"contribution\", CASE WHEN result.id_type_comptable = 1 THEN 'Dépenses' WHEN result.id_type_comptable = 2 THEN 'Recettes' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' END AS type_comptable, CASE WHEN result.rang = 0 AND result.id_type_comptable = 1 THEN 'Dépense totale' WHEN result.rang = 0 AND result.id_type_comptable = 2 THEN 'Recette totale' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' WHEN result.id_type_comptable = 1 THEN COALESCE(a.name, '') || ' - ' || COALESCE(fc.name, '') WHEN result.id_type_comptable = 2 THEN COALESCE(fdi.name, '') || ' - ' || COALESCE(v.name, '') END AS poste from ((select territoire_id, year_id, 1 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 1 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 2 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 2 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 3 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ABS(montant_euros) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\") union all (select fg.territoire_id, fg.year_id, 4 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ROUND((ABS(fg.montant_euros) / pa.population)::numeric, 2) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\" inner join (select \"dtm\".\"parent_id\" as \"territoire_id\", \"fp\".\"year_id\", SUM(fp.population) as population from \"observatoire\".\"fact_population\" as \"fp\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"fp\".\"geo_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"fp\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"fp\".\"year_id\") as \"pa\" on \"pa\".\"territoire_id\" = \"fg\".\"territoire_id\" and \"pa\".\"year_id\" = \"fg\".\"year_id\")) as \"result\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"result\".\"territoire_id\" left join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id\" = \"result\".\"poste_energetique_id\" left join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dpe\".\"activity_id\" left join \"observatoire\".\"dim_fuels\" as \"fc\" on \"fc\".\"id\" = \"dpe\".\"fuel_cat_id\" left join \"observatoire\".\"dim_filieres\" as \"fdi\" on \"fdi\".\"id\" = \"dpe\".\"filiere_detail_interne_id\" left join \"observatoire\".\"dim_vecteurs\" as \"v\" on \"v\".\"id\" = \"dpe\".\"vecteur_id\""} 
[2026-08-14 08:35:14] local.DEBUG: FactureEnergetiqueQuery {"years":[2024],"filter_geo_ids":[-730258373],"top_n":10,"sql":"select \"result\".\"territoire_id\", COALESCE(t.name, '(non rattaché)') AS territoire, \"result\".\"year_id\", \"result\".\"id_type_comptable\", \"result\".\"rang\", \"result\".\"montant_euros\", \"result\".\"contribution\", CASE WHEN result.id_type_comptable = 1 THEN 'Dépenses' WHEN result.id_type_comptable = 2 THEN 'Recettes' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' END AS type_comptable, CASE WHEN result.rang = 0 AND result.id_type_comptable = 1 THEN 'Dépense totale' WHEN result.rang = 0 AND result.id_type_comptable = 2 THEN 'Recette totale' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' WHEN result.id_type_comptable = 1 THEN COALESCE(a.name, '') || ' - ' || COALESCE(fc.name, '') WHEN result.id_type_comptable = 2 THEN COALESCE(fdi.name, '') || ' - ' || COALESCE(v.name, '') END AS poste from ((select territoire_id, year_id, 1 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 1 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 2 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 2 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 3 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ABS(montant_euros) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\") union all (select fg.territoire_id, fg.year_id, 4 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ROUND((ABS(fg.montant_euros) / pa.population)::numeric, 2) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\" inner join (select \"dtm\".\"parent_id\" as \"territoire_id\", \"fp\".\"year_id\", SUM(fp.population) as population from \"observatoire\".\"fact_population\" as \"fp\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"fp\".\"geo_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"fp\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"fp\".\"year_id\") as \"pa\" on \"pa\".\"territoire_id\" = \"fg\".\"territoire_id\" and \"pa\".\"year_id\" = \"fg\".\"year_id\")) as \"result\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"result\".\"territoire_id\" left join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id\" = \"result\".\"poste_energetique_id\" left join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dpe\".\"activity_id\" left join \"observatoire\".\"dim_fuels\" as \"fc\" on \"fc\".\"id\" = \"dpe\".\"fuel_cat_id\" left join \"observatoire\".\"dim_filieres\" as \"fdi\" on \"fdi\".\"id\" = \"dpe\".\"filiere_detail_interne_id\" left join \"observatoire\".\"dim_vecteurs\" as \"v\" on \"v\".\"id\" = \"dpe\".\"vecteur_id\""} 
[2026-08-14 08:38:25] local.DEBUG: FactureEnergetiqueQuery {"years":[2024],"filter_geo_ids":[-730258373],"top_n":10,"sql":"select \"result\".\"territoire_id\", COALESCE(t.name, '(non rattaché)') AS territoire, \"result\".\"year_id\", \"result\".\"id_type_comptable\", \"result\".\"rang\", \"result\".\"montant_euros\", \"result\".\"contribution\", CASE WHEN result.id_type_comptable = 1 THEN 'Dépenses' WHEN result.id_type_comptable = 2 THEN 'Recettes' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' END AS type_comptable, CASE WHEN result.rang = 0 AND result.id_type_comptable = 1 THEN 'Dépense totale' WHEN result.rang = 0 AND result.id_type_comptable = 2 THEN 'Recette totale' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' WHEN result.id_type_comptable = 1 THEN COALESCE(a.name, '') || ' - ' || COALESCE(fc.name, '') WHEN result.id_type_comptable = 2 THEN COALESCE(fdi.name, '') || ' - ' || COALESCE(v.name, '') END AS poste from ((select territoire_id, year_id, 1 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 1 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 2 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 2 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 3 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ABS(montant_euros) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\") union all (select fg.territoire_id, fg.year_id, 4 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ROUND((ABS(fg.montant_euros) / pa.population)::numeric, 2) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\" inner join (select \"dtm\".\"parent_id\" as \"territoire_id\", \"fp\".\"year_id\", SUM(fp.population) as population from \"observatoire\".\"fact_population\" as \"fp\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"fp\".\"geo_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"fp\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"fp\".\"year_id\") as \"pa\" on \"pa\".\"territoire_id\" = \"fg\".\"territoire_id\" and \"pa\".\"year_id\" = \"fg\".\"year_id\")) as \"result\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"result\".\"territoire_id\" left join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id\" = \"result\".\"poste_energetique_id\" left join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dpe\".\"activity_id\" left join \"observatoire\".\"dim_fuels\" as \"fc\" on \"fc\".\"id\" = \"dpe\".\"fuel_cat_id\" left join \"observatoire\".\"dim_filieres\" as \"fdi\" on \"fdi\".\"id\" = \"dpe\".\"filiere_detail_interne_id\" left join \"observatoire\".\"dim_vecteurs\" as \"v\" on \"v\".\"id\" = \"dpe\".\"vecteur_id\""} 
[2026-08-14 08:38:26] local.DEBUG: FactureEnergetiqueQuery {"years":[2024],"filter_geo_ids":[-730258373],"top_n":10,"sql":"select \"result\".\"territoire_id\", COALESCE(t.name, '(non rattaché)') AS territoire, \"result\".\"year_id\", \"result\".\"id_type_comptable\", \"result\".\"rang\", \"result\".\"montant_euros\", \"result\".\"contribution\", CASE WHEN result.id_type_comptable = 1 THEN 'Dépenses' WHEN result.id_type_comptable = 2 THEN 'Recettes' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' END AS type_comptable, CASE WHEN result.rang = 0 AND result.id_type_comptable = 1 THEN 'Dépense totale' WHEN result.rang = 0 AND result.id_type_comptable = 2 THEN 'Recette totale' WHEN result.id_type_comptable = 3 THEN 'Facture nette globale' WHEN result.id_type_comptable = 4 THEN 'Facture nette globale/hab' WHEN result.id_type_comptable = 1 THEN COALESCE(a.name, '') || ' - ' || COALESCE(fc.name, '') WHEN result.id_type_comptable = 2 THEN COALESCE(fdi.name, '') || ' - ' || COALESCE(v.name, '') END AS poste from ((select territoire_id, year_id, 1 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 1 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 2 AS id_type_comptable, poste_energetique_id, rang, montant_euros, contribution from (select a.territoire_id, a.year_id, a.poste_energetique_id, RANK() OVER (PARTITION BY a.territoire_id, a.year_id ORDER BY a.montant_euros DESC) AS rang, a.montant_euros, ROUND((a.montant_euros / t.montant_euros * 100)::numeric, 2) AS contribution from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"a\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"t\" on \"t\".\"territoire_id\" = \"a\".\"territoire_id\" and \"t\".\"year_id\" = \"a\".\"year_id\") as \"ranked\" where \"rang\" <= 10) union all (select territoire_id, year_id, 2 AS id_type_comptable, NULL::integer AS poste_energetique_id, 0::bigint AS rang, montant_euros, 100::numeric AS contribution from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"agg\") union all (select territoire_id, year_id, 3 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ABS(montant_euros) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\") union all (select fg.territoire_id, fg.year_id, 4 AS id_type_comptable, NULL::integer AS poste_energetique_id, NULL::bigint AS rang, ROUND((ABS(fg.montant_euros) / pa.population)::numeric, 2) AS montant_euros, NULL::numeric AS contribution from (select \"dt\".\"territoire_id\", \"dt\".\"year_id\", (rt.montant_euros - dt.montant_euros) as montant_euros from (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_depense_conso_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 1 and \"dpe\".\"activity_id\" = \"f\".\"activity_id\" and \"dpe\".\"fuel_cat_id\" = \"f\".\"fuel_cat_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"dt\" inner join (select \"territoire_id\", \"year_id\", SUM(montant_euros) as montant_euros from (select \"dtm\".\"parent_id\" as \"territoire_id\", \"f\".\"year_id\", \"dpe\".\"id\" as \"poste_energetique_id\", SUM(f.montant_euros) as montant_euros from \"observatoire\".\"fact_recette_prod_energetique\" as \"f\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"f\".\"geo_id\" inner join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id_type_comptable\" = 2 and \"dpe\".\"filiere_detail_interne_id\" = \"f\".\"filiere_detail_interne_id\" and \"dpe\".\"vecteur_id\" = \"f\".\"vecteur_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"f\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"f\".\"year_id\", \"dpe\".\"id\") as \"agg\" group by \"territoire_id\", \"year_id\") as \"rt\" on \"rt\".\"territoire_id\" = \"dt\".\"territoire_id\" and \"rt\".\"year_id\" = \"dt\".\"year_id\") as \"fg\" inner join (select \"dtm\".\"parent_id\" as \"territoire_id\", \"fp\".\"year_id\", SUM(fp.population) as population from \"observatoire\".\"fact_population\" as \"fp\" inner join \"observatoire\".\"dim_territory_memberships\" as \"dtm\" on \"dtm\".\"territory_id\" = \"fp\".\"geo_id\" where \"dtm\".\"parent_id\" in (-730258373) and \"fp\".\"year_id\" in (2024) group by \"dtm\".\"parent_id\", \"fp\".\"year_id\") as \"pa\" on \"pa\".\"territoire_id\" = \"fg\".\"territoire_id\" and \"pa\".\"year_id\" = \"fg\".\"year_id\")) as \"result\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"result\".\"territoire_id\" left join \"observatoire\".\"dim_postes_energetique\" as \"dpe\" on \"dpe\".\"id\" = \"result\".\"poste_energetique_id\" left join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dpe\".\"activity_id\" left join \"observatoire\".\"dim_fuels\" as \"fc\" on \"fc\".\"id\" = \"dpe\".\"fuel_cat_id\" left join \"observatoire\".\"dim_filieres\" as \"fdi\" on \"fdi\".\"id\" = \"dpe\".\"filiere_detail_interne_id\" left join \"observatoire\".\"dim_vecteurs\" as \"v\" on \"v\".\"id\" = \"dpe\".\"vecteur_id\""} 
[2026-08-14 12:02:57] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_epci","filter_level":"epci","display_level":null,"years":[2020],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, ROUND(SUM(em.pm2_5_kg)::numeric, 4) AS pm2_5_kg from \"observatoire\".\"agg_epci\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" where \"em\".\"year_id\" in (2020) and \"em\".\"geo_id\" in (-1723422958) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\""} 
[2026-08-14 12:02:58] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_epci","filter_level":"epci","display_level":null,"years":[2020],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, ROUND(SUM(em.pm2_5_kg)::numeric, 4) AS pm2_5_kg from \"observatoire\".\"agg_epci\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" where \"em\".\"year_id\" in (2020) and \"em\".\"geo_id\" in (-1723422958) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\""} 
[2026-08-14 12:04:18] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_epci","filter_level":"epci","display_level":null,"years":[2020,2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, ROUND(SUM(em.pm2_5_kg)::numeric, 4) AS pm2_5_kg from \"observatoire\".\"agg_epci\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" where \"em\".\"year_id\" in (2020, 2024) and \"em\".\"geo_id\" in (-1723422958, -997374615, -730258373, 1567286384, -1535001764, -525133160, 2043557197, -192306140, 1304264383, 597925454, -1114102449, -502440001, -2131605619, -1290362788, 904891896, 106152301, -499232206, -1473599555, -1166465414, -678691896, 1898773849, 29790987, -2098664342, -423920115, -305543184, -1489332138, -850150694, 586622372, 1078169907, 1990695804, -1267554566, -233704641, -397915175, 871304771, 453902139, 1850980260, -1084802215, -1109583266, 1124078917, 1297950547, -1458025857, 1563733864, -321157205, -1743838489, -759148196, 357382170, -490173173, -1887945636, -295462746, -158020057, -995169125, -1476708338, 1364024549, -830399312, 1281788198, 1721936645, 5512556, 34632021, -1173720275, 1625146943, 1611746287, -943236317, 256557159, 1938725061, 1140099250, -2075017474, -20355117, -30571893, 1990508546, 1460014746, 1444672102, 911530169, 1101891219, 1681914496, 1813778841, 1983858355, 943680073, -1422793355, 1505940645, 1017406998, 1477083024, 1498312074, 1246073589, 1021982571, 1334444297, 606744683, 1858439910, -1268018131, 1577096012, -386983978, -1488543839, -500685670, -1770579410, -2011014488, 725678735, -979371203, -230718315, 1035271978, -206862964, -1395209334, -583136926, -1246092032, 936707590, 1184216008, -1871040676, -301501320, 1568998603, 1352314706, 1669102578, 1544475574, 1666479923, -208929306, -1230737330, -1145724480, -632527496, 780402788, 40556270, 1822463447, 1288967671, 552500236, -878761160, -1669310148, -1225544777, 1947155941, 96267702, 89386497, -1657469405, 1160589231, 96936853, -192853748, 973743027, -1725457796, 770984370, -891326525, 1698436250, 1724376841, -887098850, 90023422, -146538989, 2086919670, 1951885443, -2024386565, 1964844930, -1651325837, 1155146790, 976323895, -2074645457, -405842380, -164560006) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\""} 
[2026-08-14 12:04:18] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_epci","filter_level":"epci","display_level":null,"years":[2020,2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, ROUND(SUM(em.pm2_5_kg)::numeric, 4) AS pm2_5_kg from \"observatoire\".\"agg_epci\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" where \"em\".\"year_id\" in (2020, 2024) and \"em\".\"geo_id\" in (-1723422958, -997374615, -730258373, 1567286384, -1535001764, -525133160, 2043557197, -192306140, 1304264383, 597925454, -1114102449, -502440001, -2131605619, -1290362788, 904891896, 106152301, -499232206, -1473599555, -1166465414, -678691896, 1898773849, 29790987, -2098664342, -423920115, -305543184, -1489332138, -850150694, 586622372, 1078169907, 1990695804, -1267554566, -233704641, -397915175, 871304771, 453902139, 1850980260, -1084802215, -1109583266, 1124078917, 1297950547, -1458025857, 1563733864, -321157205, -1743838489, -759148196, 357382170, -490173173, -1887945636, -295462746, -158020057, -995169125, -1476708338, 1364024549, -830399312, 1281788198, 1721936645, 5512556, 34632021, -1173720275, 1625146943, 1611746287, -943236317, 256557159, 1938725061, 1140099250, -2075017474, -20355117, -30571893, 1990508546, 1460014746, 1444672102, 911530169, 1101891219, 1681914496, 1813778841, 1983858355, 943680073, -1422793355, 1505940645, 1017406998, 1477083024, 1498312074, 1246073589, 1021982571, 1334444297, 606744683, 1858439910, -1268018131, 1577096012, -386983978, -1488543839, -500685670, -1770579410, -2011014488, 725678735, -979371203, -230718315, 1035271978, -206862964, -1395209334, -583136926, -1246092032, 936707590, 1184216008, -1871040676, -301501320, 1568998603, 1352314706, 1669102578, 1544475574, 1666479923, -208929306, -1230737330, -1145724480, -632527496, 780402788, 40556270, 1822463447, 1288967671, 552500236, -878761160, -1669310148, -1225544777, 1947155941, 96267702, 89386497, -1657469405, 1160589231, 96936853, -192853748, 973743027, -1725457796, 770984370, -891326525, 1698436250, 1724376841, -887098850, 90023422, -146538989, 2086919670, 1951885443, -2024386565, 1964844930, -1651325837, 1155146790, 976323895, -2074645457, -405842380, -164560006) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\""} 
[2026-08-14 12:04:39] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_epci","filter_level":"epci","display_level":null,"years":[2020,2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, ROUND(SUM(em.pm2_5_kg)::numeric, 4) AS pm2_5_kg from \"observatoire\".\"agg_epci\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" where \"em\".\"year_id\" in (2020, 2024) and \"em\".\"geo_id\" in (-1723422958, -997374615, -730258373, 1567286384, -1535001764, -525133160, 2043557197, -192306140, 1304264383, 597925454, -1114102449, -502440001, -2131605619, -1290362788, 904891896, 106152301, -499232206, -1473599555, -1166465414, -678691896, 1898773849, 29790987, -2098664342, -423920115, -305543184, -1489332138, -850150694, 586622372, 1078169907, 1990695804, -1267554566, -233704641, -397915175, 871304771, 453902139, 1850980260, -1084802215, -1109583266, 1124078917, 1297950547, -1458025857, 1563733864, -321157205, -1743838489, -759148196, 357382170, -490173173, -1887945636, -295462746, -158020057, -995169125, -1476708338, 1364024549, -830399312, 1281788198, 1721936645, 5512556, 34632021, -1173720275, 1625146943, 1611746287, -943236317, 256557159, 1938725061, 1140099250, -2075017474, -20355117, -30571893, 1990508546, 1460014746, 1444672102, 911530169, 1101891219, 1681914496, 1813778841, 1983858355, 943680073, -1422793355, 1505940645, 1017406998, 1477083024, 1498312074, 1246073589, 1021982571, 1334444297, 606744683, 1858439910, -1268018131, 1577096012, -386983978, -1488543839, -500685670, -1770579410, -2011014488, 725678735, -979371203, -230718315, 1035271978, -206862964, -1395209334, -583136926, -1246092032, 936707590, 1184216008, -1871040676, -301501320, 1568998603, 1352314706, 1669102578, 1544475574, 1666479923, -208929306, -1230737330, -1145724480, -632527496, 780402788, 40556270, 1822463447, 1288967671, 552500236, -878761160, -1669310148, -1225544777, 1947155941, 96267702, 89386497, -1657469405, 1160589231, 96936853, -192853748, 973743027, -1725457796, 770984370, -891326525, 1698436250, 1724376841, -887098850, 90023422, -146538989, 2086919670, 1951885443, -2024386565, 1964844930, -1651325837, 1155146790, 976323895, -2074645457, -405842380, -164560006) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\""} 
[2026-08-14 12:08:49] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-273970232) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'spcaet' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-1193483522, -50696485, -1460631101, -1807500046, 971904816, -1846591393, 1352484195, 1578846294, 21937287, 911083398, -244693147, -316787613, -1591836854, 342687363, -715496447, 1649769611, 317524838, 122587945, -668408596, 1915345643, -1859749546, -1744193508, 595015853, 1563060129, 747285232, 1713779118, 1757275487, -1523665978, -356747582, 46178169, 1173150921, -1805861555, -1352377836, -407252425, 2024238092, -1405923019, 1572698384, -436117987, -820564035, 1682085334, -762279866, 2110173394, -2048915241, -609915394, 33249239, -884896557, -1231239857, 1016574566, -639410621, 739923250, 540645732, -1717498989, -142018260, -301100043, -632337157, 1570062812, 942433737, -1074151148, -1839258623, -1409046242, 342527500, -248116745, -853873446, -1771225083, -799071091, 2011035759, -2125877781, -1313144583, 138601578, -1768991392, 1227983953, -794523335, -1363934197, -921669000, -809881216, -1138006003, -924061465, -973132685, -1556578693, 2134862632, -2104684761, -1273156420, -161206170) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 12:08:49] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-273970232) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'spcaet' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-1193483522, -50696485, -1460631101, -1807500046, 971904816, -1846591393, 1352484195, 1578846294, 21937287, 911083398, -244693147, -316787613, -1591836854, 342687363, -715496447, 1649769611, 317524838, 122587945, -668408596, 1915345643, -1859749546, -1744193508, 595015853, 1563060129, 747285232, 1713779118, 1757275487, -1523665978, -356747582, 46178169, 1173150921, -1805861555, -1352377836, -407252425, 2024238092, -1405923019, 1572698384, -436117987, -820564035, 1682085334, -762279866, 2110173394, -2048915241, -609915394, 33249239, -884896557, -1231239857, 1016574566, -639410621, 739923250, 540645732, -1717498989, -142018260, -301100043, -632337157, 1570062812, 942433737, -1074151148, -1839258623, -1409046242, 342527500, -248116745, -853873446, -1771225083, -799071091, 2011035759, -2125877781, -1313144583, 138601578, -1768991392, 1227983953, -794523335, -1363934197, -921669000, -809881216, -1138006003, -924061465, -973132685, -1556578693, 2134862632, -2104684761, -1273156420, -161206170) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 12:08:57] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-273970232) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'snap' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-1193483522, -50696485, -1460631101, -1807500046, 971904816, -1846591393, 1352484195, 1578846294, 21937287, 911083398, -244693147, -316787613, -1591836854, 342687363, -715496447, 1649769611, 317524838, 122587945, -668408596, 1915345643, -1859749546, -1744193508, 595015853, 1563060129, 747285232, 1713779118, 1757275487, -1523665978, -356747582, 46178169, 1173150921, -1805861555, -1352377836, -407252425, 2024238092, -1405923019, 1572698384, -436117987, -820564035, 1682085334, -762279866, 2110173394, -2048915241, -609915394, 33249239, -884896557, -1231239857, 1016574566, -639410621, 739923250, 540645732, -1717498989, -142018260, -301100043, -632337157, 1570062812, 942433737, -1074151148, -1839258623, -1409046242, 342527500, -248116745, -853873446, -1771225083, -799071091, 2011035759, -2125877781, -1313144583, 138601578, -1768991392, 1227983953, -794523335, -1363934197, -921669000, -809881216, -1138006003, -924061465, -973132685, -1556578693, 2134862632, -2104684761, -1273156420, -161206170) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 12:08:57] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-273970232) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'snap' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-1193483522, -50696485, -1460631101, -1807500046, 971904816, -1846591393, 1352484195, 1578846294, 21937287, 911083398, -244693147, -316787613, -1591836854, 342687363, -715496447, 1649769611, 317524838, 122587945, -668408596, 1915345643, -1859749546, -1744193508, 595015853, 1563060129, 747285232, 1713779118, 1757275487, -1523665978, -356747582, 46178169, 1173150921, -1805861555, -1352377836, -407252425, 2024238092, -1405923019, 1572698384, -436117987, -820564035, 1682085334, -762279866, 2110173394, -2048915241, -609915394, 33249239, -884896557, -1231239857, 1016574566, -639410621, 739923250, 540645732, -1717498989, -142018260, -301100043, -632337157, 1570062812, 942433737, -1074151148, -1839258623, -1409046242, 342527500, -248116745, -853873446, -1771225083, -799071091, 2011035759, -2125877781, -1313144583, 138601578, -1768991392, 1227983953, -794523335, -1363934197, -921669000, -809881216, -1138006003, -924061465, -973132685, -1556578693, 2134862632, -2104684761, -1273156420, -161206170) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 12:09:14] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-273970232) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'snap' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-1193483522, -50696485, -1460631101, -1807500046, 971904816, -1846591393, 1352484195, 1578846294, 21937287, 911083398, -244693147, -316787613, -1591836854, 342687363, -715496447, 1649769611, 317524838, 122587945, -668408596, 1915345643, -1859749546, -1744193508, 595015853, 1563060129, 747285232, 1713779118, 1757275487, -1523665978, -356747582, 46178169, 1173150921, -1805861555, -1352377836, -407252425, 2024238092, -1405923019, 1572698384, -436117987, -820564035, 1682085334, -762279866, 2110173394, -2048915241, -609915394, 33249239, -884896557, -1231239857, 1016574566, -639410621, 739923250, 540645732, -1717498989, -142018260, -301100043, -632337157, 1570062812, 942433737, -1074151148, -1839258623, -1409046242, 342527500, -248116745, -853873446, -1771225083, -799071091, 2011035759, -2125877781, -1313144583, 138601578, -1768991392, 1227983953, -794523335, -1363934197, -921669000, -809881216, -1138006003, -924061465, -973132685, -1556578693, 2134862632, -2104684761, -1273156420, -161206170) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 12:30:20] local.DEBUG: EstimationN1QueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"fact","source_table":"observatoire.fact_estimation_n_1","filter_level":"epci","display_level":null,"years":[2025],"sql":"select fe1.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, COALESCE(f.name, '(non rattaché)') AS combustible, ROUND((SUM(conso_ener_finale_clim_reel_gj_n1)/3.6)::numeric, 2) AS conso_ener_finale_clim_reel_gj_n1, ROUND(SUM(fe1.co2_bio_kg_n1)::numeric, 4) AS co2_bio_kg_n1, ROUND(SUM(fe1.co2_ind_kg_n1)::numeric, 4) AS co2_ind_kg_n1, ROUND(SUM(fe1.co2_kg_pcaet_n1)::numeric, 4) AS co2_kg_pcaet_n1, ROUND(SUM(fe1.ch4_kg_pcaet_n1)::numeric, 4) AS ch4_kg_pcaet_n1, ROUND(SUM(fe1.n2o_kg_pcaet_n1)::numeric, 4) AS n2o_kg_pcaet_n1, ROUND(SUM(fe1.prg_2013_teqco2_pcaet_n1)::numeric, 4) AS prg_2013_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_2021_teqco2_pcaet_n1)::numeric, 4) AS prg_2021_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_fluores_2013_teqco2_pcaet_n1)::numeric, 4) AS prg_fluores_2013_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_fluores_2021_teqco2_pcaet_n1)::numeric, 4) AS prg_fluores_2021_teqco2_pcaet_n1, ROUND(SUM(fe1.so2_kg_n1)::numeric, 4) AS so2_kg_n1, ROUND(SUM(fe1.nox_kg_n1)::numeric, 4) AS nox_kg_n1, ROUND(SUM(fe1.pm10_kg_n1)::numeric, 4) AS pm10_kg_n1, ROUND(SUM(fe1.pm2_5_kg_n1)::numeric, 4) AS pm2_5_kg_n1, ROUND(SUM(fe1.nh3_kg_n1)::numeric, 4) AS nh3_kg_n1, ROUND(SUM(fe1.covnm_kg_n1)::numeric, 4) AS covnm_kg_n1 from \"observatoire\".\"fact_estimation_n_1\" as \"fe1\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"fe1\".\"geo_id\" inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"fe1\".\"activity_pcaet_id\" inner join \"observatoire\".\"dim_fuels\" as \"f\" on \"f\".\"id\" = \"fe1\".\"fuel_cat_id\" where \"fe1\".\"year_id\" in (2025) and \"fe1\".\"geo_id\" in (-164560006) and \"fe1\".\"activity_pcaet_id\" in (-622080275, 208862058, 74904297, 1926750763, 1705942411, -273970232, -1732845089, 14022040) and \"fe1\".\"activity_secten_id\" not in (633536125, 1705364151) and \"fe1\".\"fuel_cat_id\" in (-920315543, 588797234, -1751782324, 2053746054, 1806425435, 324701552, 1761117992, 1747110739, -1099704847) group by \"fe1\".\"year_id\", \"territoire\", \"activite\", \"combustible\""} 
[2026-08-14 12:30:20] local.DEBUG: EstimationN1QueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"fact","source_table":"observatoire.fact_estimation_n_1","filter_level":"epci","display_level":null,"years":[2025],"sql":"select fe1.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, COALESCE(f.name, '(non rattaché)') AS combustible, ROUND((SUM(conso_ener_finale_clim_reel_gj_n1)/3.6)::numeric, 2) AS conso_ener_finale_clim_reel_gj_n1, ROUND(SUM(fe1.co2_bio_kg_n1)::numeric, 4) AS co2_bio_kg_n1, ROUND(SUM(fe1.co2_ind_kg_n1)::numeric, 4) AS co2_ind_kg_n1, ROUND(SUM(fe1.co2_kg_pcaet_n1)::numeric, 4) AS co2_kg_pcaet_n1, ROUND(SUM(fe1.ch4_kg_pcaet_n1)::numeric, 4) AS ch4_kg_pcaet_n1, ROUND(SUM(fe1.n2o_kg_pcaet_n1)::numeric, 4) AS n2o_kg_pcaet_n1, ROUND(SUM(fe1.prg_2013_teqco2_pcaet_n1)::numeric, 4) AS prg_2013_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_2021_teqco2_pcaet_n1)::numeric, 4) AS prg_2021_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_fluores_2013_teqco2_pcaet_n1)::numeric, 4) AS prg_fluores_2013_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_fluores_2021_teqco2_pcaet_n1)::numeric, 4) AS prg_fluores_2021_teqco2_pcaet_n1, ROUND(SUM(fe1.so2_kg_n1)::numeric, 4) AS so2_kg_n1, ROUND(SUM(fe1.nox_kg_n1)::numeric, 4) AS nox_kg_n1, ROUND(SUM(fe1.pm10_kg_n1)::numeric, 4) AS pm10_kg_n1, ROUND(SUM(fe1.pm2_5_kg_n1)::numeric, 4) AS pm2_5_kg_n1, ROUND(SUM(fe1.nh3_kg_n1)::numeric, 4) AS nh3_kg_n1, ROUND(SUM(fe1.covnm_kg_n1)::numeric, 4) AS covnm_kg_n1 from \"observatoire\".\"fact_estimation_n_1\" as \"fe1\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"fe1\".\"geo_id\" inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"fe1\".\"activity_pcaet_id\" inner join \"observatoire\".\"dim_fuels\" as \"f\" on \"f\".\"id\" = \"fe1\".\"fuel_cat_id\" where \"fe1\".\"year_id\" in (2025) and \"fe1\".\"geo_id\" in (-164560006) and \"fe1\".\"activity_pcaet_id\" in (-622080275, 208862058, 74904297, 1926750763, 1705942411, -273970232, -1732845089, 14022040) and \"fe1\".\"activity_secten_id\" not in (633536125, 1705364151) and \"fe1\".\"fuel_cat_id\" in (-920315543, 588797234, -1751782324, 2053746054, 1806425435, 324701552, 1761117992, 1747110739, -1099704847) group by \"fe1\".\"year_id\", \"territoire\", \"activite\", \"combustible\""} 
[2026-08-14 12:30:31] local.DEBUG: EstimationN1QueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"fact","source_table":"observatoire.fact_estimation_n_1","filter_level":"epci","display_level":null,"years":[2025],"sql":"select fe1.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, COALESCE(f.name, '(non rattaché)') AS combustible, ROUND((SUM(conso_ener_finale_clim_reel_gj_n1)/3.6)::numeric, 2) AS conso_ener_finale_clim_reel_gj_n1, ROUND(SUM(fe1.co2_bio_kg_n1)::numeric, 4) AS co2_bio_kg_n1, ROUND(SUM(fe1.co2_ind_kg_n1)::numeric, 4) AS co2_ind_kg_n1, ROUND(SUM(fe1.co2_kg_pcaet_n1)::numeric, 4) AS co2_kg_pcaet_n1, ROUND(SUM(fe1.ch4_kg_pcaet_n1)::numeric, 4) AS ch4_kg_pcaet_n1, ROUND(SUM(fe1.n2o_kg_pcaet_n1)::numeric, 4) AS n2o_kg_pcaet_n1, ROUND(SUM(fe1.prg_2013_teqco2_pcaet_n1)::numeric, 4) AS prg_2013_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_2021_teqco2_pcaet_n1)::numeric, 4) AS prg_2021_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_fluores_2013_teqco2_pcaet_n1)::numeric, 4) AS prg_fluores_2013_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_fluores_2021_teqco2_pcaet_n1)::numeric, 4) AS prg_fluores_2021_teqco2_pcaet_n1, ROUND(SUM(fe1.so2_kg_n1)::numeric, 4) AS so2_kg_n1, ROUND(SUM(fe1.nox_kg_n1)::numeric, 4) AS nox_kg_n1, ROUND(SUM(fe1.pm10_kg_n1)::numeric, 4) AS pm10_kg_n1, ROUND(SUM(fe1.pm2_5_kg_n1)::numeric, 4) AS pm2_5_kg_n1, ROUND(SUM(fe1.nh3_kg_n1)::numeric, 4) AS nh3_kg_n1, ROUND(SUM(fe1.covnm_kg_n1)::numeric, 4) AS covnm_kg_n1 from \"observatoire\".\"fact_estimation_n_1\" as \"fe1\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"fe1\".\"geo_id\" inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"fe1\".\"activity_pcaet_id\" inner join \"observatoire\".\"dim_fuels\" as \"f\" on \"f\".\"id\" = \"fe1\".\"fuel_cat_id\" where \"fe1\".\"year_id\" in (2025) and \"fe1\".\"geo_id\" in (-164560006) and \"fe1\".\"activity_pcaet_id\" in (-622080275, 208862058, 74904297, 1926750763, 1705942411, -273970232, -1732845089, 14022040) and \"fe1\".\"activity_secten_id\" not in (633536125, 1705364151) and \"fe1\".\"fuel_cat_id\" in (-920315543, 588797234, -1751782324, 2053746054, 1806425435, 324701552, 1761117992, 1747110739, -1099704847) group by \"fe1\".\"year_id\", \"territoire\", \"activite\", \"combustible\""} 
[2026-08-14 12:30:56] local.DEBUG: EstimationN1QueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"fact","source_table":"observatoire.fact_estimation_n_1","filter_level":"epci","display_level":null,"years":[2025],"sql":"select fe1.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, COALESCE(f.name, '(non rattaché)') AS combustible, ROUND((SUM(conso_ener_finale_clim_reel_gj_n1)/3.6)::numeric, 2) AS conso_ener_finale_clim_reel_gj_n1, ROUND(SUM(fe1.co2_bio_kg_n1)::numeric, 4) AS co2_bio_kg_n1, ROUND(SUM(fe1.co2_ind_kg_n1)::numeric, 4) AS co2_ind_kg_n1, ROUND(SUM(fe1.co2_kg_pcaet_n1)::numeric, 4) AS co2_kg_pcaet_n1, ROUND(SUM(fe1.ch4_kg_pcaet_n1)::numeric, 4) AS ch4_kg_pcaet_n1, ROUND(SUM(fe1.n2o_kg_pcaet_n1)::numeric, 4) AS n2o_kg_pcaet_n1, ROUND(SUM(fe1.prg_2013_teqco2_pcaet_n1)::numeric, 4) AS prg_2013_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_2021_teqco2_pcaet_n1)::numeric, 4) AS prg_2021_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_fluores_2013_teqco2_pcaet_n1)::numeric, 4) AS prg_fluores_2013_teqco2_pcaet_n1, ROUND(SUM(fe1.prg_fluores_2021_teqco2_pcaet_n1)::numeric, 4) AS prg_fluores_2021_teqco2_pcaet_n1, ROUND(SUM(fe1.so2_kg_n1)::numeric, 4) AS so2_kg_n1, ROUND(SUM(fe1.nox_kg_n1)::numeric, 4) AS nox_kg_n1, ROUND(SUM(fe1.pm10_kg_n1)::numeric, 4) AS pm10_kg_n1, ROUND(SUM(fe1.pm2_5_kg_n1)::numeric, 4) AS pm2_5_kg_n1, ROUND(SUM(fe1.nh3_kg_n1)::numeric, 4) AS nh3_kg_n1, ROUND(SUM(fe1.covnm_kg_n1)::numeric, 4) AS covnm_kg_n1 from \"observatoire\".\"fact_estimation_n_1\" as \"fe1\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"fe1\".\"geo_id\" inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"fe1\".\"activity_pcaet_id\" inner join \"observatoire\".\"dim_fuels\" as \"f\" on \"f\".\"id\" = \"fe1\".\"fuel_cat_id\" where \"fe1\".\"year_id\" in (2025) and \"fe1\".\"geo_id\" in (-164560006) and \"fe1\".\"activity_pcaet_id\" in (-622080275, 208862058, 74904297, 1926750763, 1705942411, -273970232, -1732845089, 14022040) and \"fe1\".\"activity_secten_id\" not in (633536125, 1705364151) and \"fe1\".\"fuel_cat_id\" in (-920315543, 588797234, -1751782324, 2053746054, 1806425435, 324701552, 1761117992, 1747110739, -1099704847) group by \"fe1\".\"year_id\", \"territoire\", \"activite\", \"combustible\""} 
[2026-08-14 12:39:07] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.nh3_kg)::numeric, 4) AS nh3_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-622080275) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'snap' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-843932025, -1915212800, -1645230407, -697951920, 118055960, 2128833364, -567369811, 310956635, -1918263047, -1246034248, -1144004711, 1839125859, -1345162752, 1735525248, -1978708979, 1574055369, 1663401832, -1987478087, -1171478393, 1770243570, -818258464, 1763501654, -893109849, 85619372, 350725182, -182420025, -1279064480, 775840687, -38219474, 1303189715, 1996142013, -183191368, -1110362267, 1734631443, -1781860008, -2140441286, 921165895, -966852427, 1784442077, 2101539831, 2106414096, -197558611, -2019686765, -1912564262, -694125069, -1166060768, -1929400904, 1741715211, -73273843, -604604043, 1371033649, 776279000, -1951358321, -475198975, 859934642, -1334310062, 344405547, -388600018, -955858860, 409891242, 1207010603, -1320908412, 1978588983, -263558204, 725270159, -1689620327, -394200259, 254882134, -1432964826, 971161973, -1573937312, 1983248498, -620524373, -1259394394, -1715977758, -115032065, 1173327443, -1710809284, -913831972) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 12:39:07] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.nh3_kg)::numeric, 4) AS nh3_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-622080275) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'snap' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-843932025, -1915212800, -1645230407, -697951920, 118055960, 2128833364, -567369811, 310956635, -1918263047, -1246034248, -1144004711, 1839125859, -1345162752, 1735525248, -1978708979, 1574055369, 1663401832, -1987478087, -1171478393, 1770243570, -818258464, 1763501654, -893109849, 85619372, 350725182, -182420025, -1279064480, 775840687, -38219474, 1303189715, 1996142013, -183191368, -1110362267, 1734631443, -1781860008, -2140441286, 921165895, -966852427, 1784442077, 2101539831, 2106414096, -197558611, -2019686765, -1912564262, -694125069, -1166060768, -1929400904, 1741715211, -73273843, -604604043, 1371033649, 776279000, -1951358321, -475198975, 859934642, -1334310062, 344405547, -388600018, -955858860, 409891242, 1207010603, -1320908412, 1978588983, -263558204, 725270159, -1689620327, -394200259, 254882134, -1432964826, 971161973, -1573937312, 1983248498, -620524373, -1259394394, -1715977758, -115032065, 1173327443, -1710809284, -913831972) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 12:39:09] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.nh3_kg)::numeric, 4) AS nh3_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-622080275) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'snap' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-843932025, -1915212800, -1645230407, -697951920, 118055960, 2128833364, -567369811, 310956635, -1918263047, -1246034248, -1144004711, 1839125859, -1345162752, 1735525248, -1978708979, 1574055369, 1663401832, -1987478087, -1171478393, 1770243570, -818258464, 1763501654, -893109849, 85619372, 350725182, -182420025, -1279064480, 775840687, -38219474, 1303189715, 1996142013, -183191368, -1110362267, 1734631443, -1781860008, -2140441286, 921165895, -966852427, 1784442077, 2101539831, 2106414096, -197558611, -2019686765, -1912564262, -694125069, -1166060768, -1929400904, 1741715211, -73273843, -604604043, 1371033649, 776279000, -1951358321, -475198975, 859934642, -1334310062, 344405547, -388600018, -955858860, 409891242, 1207010603, -1320908412, 1978588983, -263558204, 725270159, -1689620327, -394200259, 254882134, -1432964826, 971161973, -1573937312, 1983248498, -620524373, -1259394394, -1715977758, -115032065, 1173327443, -1710809284, -913831972) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 12:57:34] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-622080275, 208862058, 74904297, 1926750763, 1705942411, -273970232, -1732845089, 14022040) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-2065015321, 1664202072, -1468143007, 1108698765, -697951920, 53616376, 911083398, -2129813176, -1918263047, -393206791, 562718587, 439277546, -858228785, 1839125859, 1824025864, 254468532, 1735525248, 240491429, 751538419, 1662919374, 1660135024, -2109039919, 97436677, -124660711, -1987478087, 722905366, -93516697, -818258464, -1982109166, 1409930224, -2034818798, 1822307428, -1758060949, 155019705, 1869212529, -609915394, 1481894613, 1395794963, 1695347196, 64335092, 921165895, -142018260, -482664252, 26668268, 942433737, 2101539831, -556896478, -289004236, 1180149453, -1100601087, 2113546912, -1166060768, -1270919973, 1741715211, -604604043, -1323823743, -65650287, -1771225083, 556015237, -497458774, 1890006254, -717879577, -475198975, 1306594475, 1087885866, -893165577, -1618922050, 409891242, -2075398489, 865842982, 1765509547, -1487210095, 76265396, 503239948, 1329377505, -2004721785, -1859723360, 1648387281, -731418973, -924061465, -519499276, -1689620327, 571578548, 1372013544, -2017652732, 506491597, 333711349, -1807500046, 680092381, 28083642, 879051533, -1167947622, 1900723648, -198132915, -567369811, 1273925006, 719954458, 1659802002, -1605866945, 1251539306, -1246034248, -2000350303, 122587945, 1855887801, 1307996793, -797747832, 1915345643, -719653191, -574407755, 747285232, 1757275487, 1312649538, 660808751, 1444864905, 82030098, 937605621, -1352377836, -407252425, 1763501654, -1405923019, 350725182, 1824837113, -1560607589, 682492730, 1303189715, 1734631443, 1243082219, 1140080948, -966852427, -632337157, 1663741761, -567757160, -1887790066, -837308181, -1623725498, -1436585389, -248116745, 2079193929, 1285586024, -1749430722, -717359299, -98448292, -853873446, -762838756, 1974523832, -1736763325, 859934642, 760580929, 1658855321, 138601578, 1153344103, 1280935296, -1951484904, 725270159, -1104146686, -225028528, -469721241, -1445420861, -2104684761, -1259394394, 1942080707, -913831972, 350561514, 1206983340, 1633334487, -1017289816, -843932025, -337017078, 454621909, 41079158, -1846591393, 804338617, 1352484195, 1426270099, -1732290900, 1353783048, -1078990055, -307626332, 2128833364, 1054770029, -740347188, -1430328674, 730376509, 504001257, -1859749546, -435776990, -2102767552, -933330074, 112476696, -446796902, -1546313589, 1663401832, 1104829866, -323474854, 906942419, -2009648112, -1608512036, 489987876, 301093584, 1663410790, -820564035, 1066750091, 2110173394, -2048915241, 859987309, 1134610842, -1219234331, 1099679168, 1855856603, -964500217, 21511964, 1388087176, 1967813158, -1063238036, -570672305, 2106414096, 1913359952, -2145734036, 342527500, 429059437, -295738415, -376271361, 827134186, 2047409618, 1519990054, -1487774563, 153764150, 1371033649, 776279000, 692870153, -1951358321, -889255393, 905336003, -1528757905, -1313144583, -189572407, 1219243506, -1959662381, -667330531, -1327037360, -388600018, -1768991392, 631501363, 1428443613, -794523335, -921669000, 50809254, -1151061648, -263558204, -1316167746, 254882134, -1432964826, 971161973, -869291431, -92274995, 2001828071, 717533312, -919698739, -115032065, -1710809284, 1440646841, 438839785, 1838130794, -1438657658, -2100037337, -1645230407, -35163706, -244693147, 747547873, -178006637, -316787613, -1609021450, 425592013, 1142721112, 1125960239, 342687363, -715496447, -466654990, -22267807, 2004972987, 373557710, -538767368, -583628804, 1231105243, -148499659, -1978708979, 1035684050, 595015853, 1713779118, 530155604, 1319740754, -1878882180, -578878727, 46178169, 1173150921, 707403387, 595454509, 2093595260, -178885722, 1933574569, 1689971204, 2099170107, -23642967, -893109849, -394754806, -1052690536, 373550100, -1337323363, 1447225472, 1276215965, 33249239, 730336352, -639410621, 932667705, -1839258623, 1911698987, -37699356, -982013561, -1459018491, -883327242, 1252179801, -450105656, -799071091, -1118403434, -432827018, -2125877781, -1464392700, -1334310062, 1371610371, -1652853783, 2106513667, -1320908412, -1981687934, 1764341119, -457559919, -1414713643, -394200259, -1573937312, -1087220802, 1173327443, 1942963054, -1193483522, 575519546, 1411111401, -50696485, -390568655, -1496086086, -273047452, 1578846294, -1189987097, -366685926, -390542442, 310956635, 494216435, -1591836854, -1958561345, 2001630306, -1144004711, 942233085, -1824930634, -35558533, -1345162752, 1713162907, -600367835, -1294709678, -356747582, -761498023, -1171478393, -487172781, -1805861555, 1024219564, 579293477, 1140113838, -1419278172, 2024238092, -182420025, -1904591798, 2117082238, 1974281097, -1743267982, -919487101, -770400240, -1939219148, 1687214361, -543242059, 1687613177, 692025924, 1949554747, -1071587566, 216692383, -1231239857, -301100043, 1184608045, 1570062812, 1744165561, -2024511393, -2117292693, -183910117, -1210454800, 933754793, 1924478818, 1584015331, -1929400904, -1865280307, 589008399, -125964541, 1640238785, -1829002824, 1898736760, 2108532170, 1044726750, 1923261691, 1227983953, -1363934197, 384410393, -2044885611, 919914692, 736532642, -1239747894, -1632648707, 2134862632, 1386497909, -1028097404, -1390684557, 2139709518, -1273156420, 1222056809, 539391017, 515802054, -2129230707, -1408995398, 632880332, 1772504308, -966063115, -1799725714, 21937287, 1477165581, 1253744553, 203783501, 1236677003, 689872, 1075533786, 1649769611, -97814566, -337441085, 675577244, 1367391544, 1379603351, 1049700765, 847335499, -14567500, -118886754, 1563060129, -1287483713, 1574055369, -1513139721, -1389614002, -1144038162, 775868583, -606258386, -1987052516, 1855178673, -2044004547, -1581253380, 1201608055, 85619372, -68842748, -1279064480, 2005250983, -307341145, 1996142013, 375123593, -271055130, -1781860008, 1096813866, 1849745898, 1007707851, -1605275342, -2140441286, 739923250, -704377305, -467115791, 1079222860, 242615640, -1837178453, 318613241, 347811431, -197558611, -2019686765, -980556544, 1553348267, 494206472, 1112036812, 1258750298, -842445917, 1544265955, -1912564262, -620488471, -889282158, 1299296056, 423665295, 1359890860, 1077172953, -73273843, -1659840926, 1392617912, -1081530607, 1303291967, 392392088, -2017022783, 1184793512, -1869570613, -955858860, 340061913, 618379975, 1011823494, -809881216, 1816787957, 1978588983, -1138006003, 2078237231, 1842692073, -620524373, -1715977758, -939991847, 1418466514, 1620817717, 1901794668, -1390883660, 1843164580, 1743133853, 578558002, -1932993837, -858994155, -1461717196, 1528030456, 1435696692, -648559285, -302632139, -1607714348, 223376167, 1711779466, 317524838, -1082127435, -1990228258, -668408596, 548540297, 1651542945, -1614026445, -1832238632, -1037581785, -1523665978, 600270447, -574372648, -763786315, 283393782, 1770243570, -734407698, -1703285931, -327559973, -1788065014, 960709480, -1814854069, -908948374, -436117987, 1682085334, -762279866, -183191368, 220080184, -57766241, -676428704, 1598532481, -1255434042, 1989286800, -1717498989, 1784442077, -1337246483, 1458785475, -1332638305, 145755964, -1074151148, 1287376035, 1362332800, 224035916, -23479538, -1409046242, -694125069, -566762324, -630866531, -347269928, 679566165, 276545043, 366390502, 288394184, -1914964681, -1286440751, -2020552257, 1678295557, -443199195, -1935636633, 2101386234, 818513443, -708582396, 1983248498, -1871954656, -161206170, -1859668546, -1151541471, 988479706, -1460631101, 971904816, -1519785494, -1915212800, -1888967964, -1802228876, -1296777115, 1201309406, -1531584106, 826582647, 118055960, -1132107069, -373631934, -1371339394, -1940516137, 1127749479, 1201351105, 68476456, -1744193508, -306861080, -980025384, -2072230927, -1736978617, 1572698384, 1177367976, -1156123924, 775840687, -1727327625, -38219474, -2063183380, -1110362267, 1684813422, -884896557, 1016574566, 803377337, 540645732, -1240017080, -1178332843, 2034593037, 1429295941, 1034344725, 1381736146, -62446596, -833249209, 1611256781, -1200401518, -518501295, 1572749265, -807863775, -746688917, 1656148124, -1201074141, 922162158, 302308805, 2079850451, 1040750617, 2011035759, 1436256879, 344405547, 1340950393, 1207010603, 1972919535, -2062377130, -975191328, -973132685, -1556578693, 931702417, -1990261158, 35115389, -1650124362, 500851691, -1315688156) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite\""} 
[2026-08-14 12:57:35] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-622080275, 208862058, 74904297, 1926750763, 1705942411, -273970232, -1732845089, 14022040) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-2065015321, 1664202072, -1468143007, 1108698765, -697951920, 53616376, 911083398, -2129813176, -1918263047, -393206791, 562718587, 439277546, -858228785, 1839125859, 1824025864, 254468532, 1735525248, 240491429, 751538419, 1662919374, 1660135024, -2109039919, 97436677, -124660711, -1987478087, 722905366, -93516697, -818258464, -1982109166, 1409930224, -2034818798, 1822307428, -1758060949, 155019705, 1869212529, -609915394, 1481894613, 1395794963, 1695347196, 64335092, 921165895, -142018260, -482664252, 26668268, 942433737, 2101539831, -556896478, -289004236, 1180149453, -1100601087, 2113546912, -1166060768, -1270919973, 1741715211, -604604043, -1323823743, -65650287, -1771225083, 556015237, -497458774, 1890006254, -717879577, -475198975, 1306594475, 1087885866, -893165577, -1618922050, 409891242, -2075398489, 865842982, 1765509547, -1487210095, 76265396, 503239948, 1329377505, -2004721785, -1859723360, 1648387281, -731418973, -924061465, -519499276, -1689620327, 571578548, 1372013544, -2017652732, 506491597, 333711349, -1807500046, 680092381, 28083642, 879051533, -1167947622, 1900723648, -198132915, -567369811, 1273925006, 719954458, 1659802002, -1605866945, 1251539306, -1246034248, -2000350303, 122587945, 1855887801, 1307996793, -797747832, 1915345643, -719653191, -574407755, 747285232, 1757275487, 1312649538, 660808751, 1444864905, 82030098, 937605621, -1352377836, -407252425, 1763501654, -1405923019, 350725182, 1824837113, -1560607589, 682492730, 1303189715, 1734631443, 1243082219, 1140080948, -966852427, -632337157, 1663741761, -567757160, -1887790066, -837308181, -1623725498, -1436585389, -248116745, 2079193929, 1285586024, -1749430722, -717359299, -98448292, -853873446, -762838756, 1974523832, -1736763325, 859934642, 760580929, 1658855321, 138601578, 1153344103, 1280935296, -1951484904, 725270159, -1104146686, -225028528, -469721241, -1445420861, -2104684761, -1259394394, 1942080707, -913831972, 350561514, 1206983340, 1633334487, -1017289816, -843932025, -337017078, 454621909, 41079158, -1846591393, 804338617, 1352484195, 1426270099, -1732290900, 1353783048, -1078990055, -307626332, 2128833364, 1054770029, -740347188, -1430328674, 730376509, 504001257, -1859749546, -435776990, -2102767552, -933330074, 112476696, -446796902, -1546313589, 1663401832, 1104829866, -323474854, 906942419, -2009648112, -1608512036, 489987876, 301093584, 1663410790, -820564035, 1066750091, 2110173394, -2048915241, 859987309, 1134610842, -1219234331, 1099679168, 1855856603, -964500217, 21511964, 1388087176, 1967813158, -1063238036, -570672305, 2106414096, 1913359952, -2145734036, 342527500, 429059437, -295738415, -376271361, 827134186, 2047409618, 1519990054, -1487774563, 153764150, 1371033649, 776279000, 692870153, -1951358321, -889255393, 905336003, -1528757905, -1313144583, -189572407, 1219243506, -1959662381, -667330531, -1327037360, -388600018, -1768991392, 631501363, 1428443613, -794523335, -921669000, 50809254, -1151061648, -263558204, -1316167746, 254882134, -1432964826, 971161973, -869291431, -92274995, 2001828071, 717533312, -919698739, -115032065, -1710809284, 1440646841, 438839785, 1838130794, -1438657658, -2100037337, -1645230407, -35163706, -244693147, 747547873, -178006637, -316787613, -1609021450, 425592013, 1142721112, 1125960239, 342687363, -715496447, -466654990, -22267807, 2004972987, 373557710, -538767368, -583628804, 1231105243, -148499659, -1978708979, 1035684050, 595015853, 1713779118, 530155604, 1319740754, -1878882180, -578878727, 46178169, 1173150921, 707403387, 595454509, 2093595260, -178885722, 1933574569, 1689971204, 2099170107, -23642967, -893109849, -394754806, -1052690536, 373550100, -1337323363, 1447225472, 1276215965, 33249239, 730336352, -639410621, 932667705, -1839258623, 1911698987, -37699356, -982013561, -1459018491, -883327242, 1252179801, -450105656, -799071091, -1118403434, -432827018, -2125877781, -1464392700, -1334310062, 1371610371, -1652853783, 2106513667, -1320908412, -1981687934, 1764341119, -457559919, -1414713643, -394200259, -1573937312, -1087220802, 1173327443, 1942963054, -1193483522, 575519546, 1411111401, -50696485, -390568655, -1496086086, -273047452, 1578846294, -1189987097, -366685926, -390542442, 310956635, 494216435, -1591836854, -1958561345, 2001630306, -1144004711, 942233085, -1824930634, -35558533, -1345162752, 1713162907, -600367835, -1294709678, -356747582, -761498023, -1171478393, -487172781, -1805861555, 1024219564, 579293477, 1140113838, -1419278172, 2024238092, -182420025, -1904591798, 2117082238, 1974281097, -1743267982, -919487101, -770400240, -1939219148, 1687214361, -543242059, 1687613177, 692025924, 1949554747, -1071587566, 216692383, -1231239857, -301100043, 1184608045, 1570062812, 1744165561, -2024511393, -2117292693, -183910117, -1210454800, 933754793, 1924478818, 1584015331, -1929400904, -1865280307, 589008399, -125964541, 1640238785, -1829002824, 1898736760, 2108532170, 1044726750, 1923261691, 1227983953, -1363934197, 384410393, -2044885611, 919914692, 736532642, -1239747894, -1632648707, 2134862632, 1386497909, -1028097404, -1390684557, 2139709518, -1273156420, 1222056809, 539391017, 515802054, -2129230707, -1408995398, 632880332, 1772504308, -966063115, -1799725714, 21937287, 1477165581, 1253744553, 203783501, 1236677003, 689872, 1075533786, 1649769611, -97814566, -337441085, 675577244, 1367391544, 1379603351, 1049700765, 847335499, -14567500, -118886754, 1563060129, -1287483713, 1574055369, -1513139721, -1389614002, -1144038162, 775868583, -606258386, -1987052516, 1855178673, -2044004547, -1581253380, 1201608055, 85619372, -68842748, -1279064480, 2005250983, -307341145, 1996142013, 375123593, -271055130, -1781860008, 1096813866, 1849745898, 1007707851, -1605275342, -2140441286, 739923250, -704377305, -467115791, 1079222860, 242615640, -1837178453, 318613241, 347811431, -197558611, -2019686765, -980556544, 1553348267, 494206472, 1112036812, 1258750298, -842445917, 1544265955, -1912564262, -620488471, -889282158, 1299296056, 423665295, 1359890860, 1077172953, -73273843, -1659840926, 1392617912, -1081530607, 1303291967, 392392088, -2017022783, 1184793512, -1869570613, -955858860, 340061913, 618379975, 1011823494, -809881216, 1816787957, 1978588983, -1138006003, 2078237231, 1842692073, -620524373, -1715977758, -939991847, 1418466514, 1620817717, 1901794668, -1390883660, 1843164580, 1743133853, 578558002, -1932993837, -858994155, -1461717196, 1528030456, 1435696692, -648559285, -302632139, -1607714348, 223376167, 1711779466, 317524838, -1082127435, -1990228258, -668408596, 548540297, 1651542945, -1614026445, -1832238632, -1037581785, -1523665978, 600270447, -574372648, -763786315, 283393782, 1770243570, -734407698, -1703285931, -327559973, -1788065014, 960709480, -1814854069, -908948374, -436117987, 1682085334, -762279866, -183191368, 220080184, -57766241, -676428704, 1598532481, -1255434042, 1989286800, -1717498989, 1784442077, -1337246483, 1458785475, -1332638305, 145755964, -1074151148, 1287376035, 1362332800, 224035916, -23479538, -1409046242, -694125069, -566762324, -630866531, -347269928, 679566165, 276545043, 366390502, 288394184, -1914964681, -1286440751, -2020552257, 1678295557, -443199195, -1935636633, 2101386234, 818513443, -708582396, 1983248498, -1871954656, -161206170, -1859668546, -1151541471, 988479706, -1460631101, 971904816, -1519785494, -1915212800, -1888967964, -1802228876, -1296777115, 1201309406, -1531584106, 826582647, 118055960, -1132107069, -373631934, -1371339394, -1940516137, 1127749479, 1201351105, 68476456, -1744193508, -306861080, -980025384, -2072230927, -1736978617, 1572698384, 1177367976, -1156123924, 775840687, -1727327625, -38219474, -2063183380, -1110362267, 1684813422, -884896557, 1016574566, 803377337, 540645732, -1240017080, -1178332843, 2034593037, 1429295941, 1034344725, 1381736146, -62446596, -833249209, 1611256781, -1200401518, -518501295, 1572749265, -807863775, -746688917, 1656148124, -1201074141, 922162158, 302308805, 2079850451, 1040750617, 2011035759, 1436256879, 344405547, 1340950393, 1207010603, 1972919535, -2062377130, -975191328, -973132685, -1556578693, 931702417, -1990261158, 35115389, -1650124362, 500851691, -1315688156) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite\""} 
[2026-08-14 12:57:37] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (-622080275, 208862058, 74904297, 1926750763, 1705942411, -273970232, -1732845089, 14022040) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (-2065015321, 1664202072, -1468143007, 1108698765, -697951920, 53616376, 911083398, -2129813176, -1918263047, -393206791, 562718587, 439277546, -858228785, 1839125859, 1824025864, 254468532, 1735525248, 240491429, 751538419, 1662919374, 1660135024, -2109039919, 97436677, -124660711, -1987478087, 722905366, -93516697, -818258464, -1982109166, 1409930224, -2034818798, 1822307428, -1758060949, 155019705, 1869212529, -609915394, 1481894613, 1395794963, 1695347196, 64335092, 921165895, -142018260, -482664252, 26668268, 942433737, 2101539831, -556896478, -289004236, 1180149453, -1100601087, 2113546912, -1166060768, -1270919973, 1741715211, -604604043, -1323823743, -65650287, -1771225083, 556015237, -497458774, 1890006254, -717879577, -475198975, 1306594475, 1087885866, -893165577, -1618922050, 409891242, -2075398489, 865842982, 1765509547, -1487210095, 76265396, 503239948, 1329377505, -2004721785, -1859723360, 1648387281, -731418973, -924061465, -519499276, -1689620327, 571578548, 1372013544, -2017652732, 506491597, 333711349, -1807500046, 680092381, 28083642, 879051533, -1167947622, 1900723648, -198132915, -567369811, 1273925006, 719954458, 1659802002, -1605866945, 1251539306, -1246034248, -2000350303, 122587945, 1855887801, 1307996793, -797747832, 1915345643, -719653191, -574407755, 747285232, 1757275487, 1312649538, 660808751, 1444864905, 82030098, 937605621, -1352377836, -407252425, 1763501654, -1405923019, 350725182, 1824837113, -1560607589, 682492730, 1303189715, 1734631443, 1243082219, 1140080948, -966852427, -632337157, 1663741761, -567757160, -1887790066, -837308181, -1623725498, -1436585389, -248116745, 2079193929, 1285586024, -1749430722, -717359299, -98448292, -853873446, -762838756, 1974523832, -1736763325, 859934642, 760580929, 1658855321, 138601578, 1153344103, 1280935296, -1951484904, 725270159, -1104146686, -225028528, -469721241, -1445420861, -2104684761, -1259394394, 1942080707, -913831972, 350561514, 1206983340, 1633334487, -1017289816, -843932025, -337017078, 454621909, 41079158, -1846591393, 804338617, 1352484195, 1426270099, -1732290900, 1353783048, -1078990055, -307626332, 2128833364, 1054770029, -740347188, -1430328674, 730376509, 504001257, -1859749546, -435776990, -2102767552, -933330074, 112476696, -446796902, -1546313589, 1663401832, 1104829866, -323474854, 906942419, -2009648112, -1608512036, 489987876, 301093584, 1663410790, -820564035, 1066750091, 2110173394, -2048915241, 859987309, 1134610842, -1219234331, 1099679168, 1855856603, -964500217, 21511964, 1388087176, 1967813158, -1063238036, -570672305, 2106414096, 1913359952, -2145734036, 342527500, 429059437, -295738415, -376271361, 827134186, 2047409618, 1519990054, -1487774563, 153764150, 1371033649, 776279000, 692870153, -1951358321, -889255393, 905336003, -1528757905, -1313144583, -189572407, 1219243506, -1959662381, -667330531, -1327037360, -388600018, -1768991392, 631501363, 1428443613, -794523335, -921669000, 50809254, -1151061648, -263558204, -1316167746, 254882134, -1432964826, 971161973, -869291431, -92274995, 2001828071, 717533312, -919698739, -115032065, -1710809284, 1440646841, 438839785, 1838130794, -1438657658, -2100037337, -1645230407, -35163706, -244693147, 747547873, -178006637, -316787613, -1609021450, 425592013, 1142721112, 1125960239, 342687363, -715496447, -466654990, -22267807, 2004972987, 373557710, -538767368, -583628804, 1231105243, -148499659, -1978708979, 1035684050, 595015853, 1713779118, 530155604, 1319740754, -1878882180, -578878727, 46178169, 1173150921, 707403387, 595454509, 2093595260, -178885722, 1933574569, 1689971204, 2099170107, -23642967, -893109849, -394754806, -1052690536, 373550100, -1337323363, 1447225472, 1276215965, 33249239, 730336352, -639410621, 932667705, -1839258623, 1911698987, -37699356, -982013561, -1459018491, -883327242, 1252179801, -450105656, -799071091, -1118403434, -432827018, -2125877781, -1464392700, -1334310062, 1371610371, -1652853783, 2106513667, -1320908412, -1981687934, 1764341119, -457559919, -1414713643, -394200259, -1573937312, -1087220802, 1173327443, 1942963054, -1193483522, 575519546, 1411111401, -50696485, -390568655, -1496086086, -273047452, 1578846294, -1189987097, -366685926, -390542442, 310956635, 494216435, -1591836854, -1958561345, 2001630306, -1144004711, 942233085, -1824930634, -35558533, -1345162752, 1713162907, -600367835, -1294709678, -356747582, -761498023, -1171478393, -487172781, -1805861555, 1024219564, 579293477, 1140113838, -1419278172, 2024238092, -182420025, -1904591798, 2117082238, 1974281097, -1743267982, -919487101, -770400240, -1939219148, 1687214361, -543242059, 1687613177, 692025924, 1949554747, -1071587566, 216692383, -1231239857, -301100043, 1184608045, 1570062812, 1744165561, -2024511393, -2117292693, -183910117, -1210454800, 933754793, 1924478818, 1584015331, -1929400904, -1865280307, 589008399, -125964541, 1640238785, -1829002824, 1898736760, 2108532170, 1044726750, 1923261691, 1227983953, -1363934197, 384410393, -2044885611, 919914692, 736532642, -1239747894, -1632648707, 2134862632, 1386497909, -1028097404, -1390684557, 2139709518, -1273156420, 1222056809, 539391017, 515802054, -2129230707, -1408995398, 632880332, 1772504308, -966063115, -1799725714, 21937287, 1477165581, 1253744553, 203783501, 1236677003, 689872, 1075533786, 1649769611, -97814566, -337441085, 675577244, 1367391544, 1379603351, 1049700765, 847335499, -14567500, -118886754, 1563060129, -1287483713, 1574055369, -1513139721, -1389614002, -1144038162, 775868583, -606258386, -1987052516, 1855178673, -2044004547, -1581253380, 1201608055, 85619372, -68842748, -1279064480, 2005250983, -307341145, 1996142013, 375123593, -271055130, -1781860008, 1096813866, 1849745898, 1007707851, -1605275342, -2140441286, 739923250, -704377305, -467115791, 1079222860, 242615640, -1837178453, 318613241, 347811431, -197558611, -2019686765, -980556544, 1553348267, 494206472, 1112036812, 1258750298, -842445917, 1544265955, -1912564262, -620488471, -889282158, 1299296056, 423665295, 1359890860, 1077172953, -73273843, -1659840926, 1392617912, -1081530607, 1303291967, 392392088, -2017022783, 1184793512, -1869570613, -955858860, 340061913, 618379975, 1011823494, -809881216, 1816787957, 1978588983, -1138006003, 2078237231, 1842692073, -620524373, -1715977758, -939991847, 1418466514, 1620817717, 1901794668, -1390883660, 1843164580, 1743133853, 578558002, -1932993837, -858994155, -1461717196, 1528030456, 1435696692, -648559285, -302632139, -1607714348, 223376167, 1711779466, 317524838, -1082127435, -1990228258, -668408596, 548540297, 1651542945, -1614026445, -1832238632, -1037581785, -1523665978, 600270447, -574372648, -763786315, 283393782, 1770243570, -734407698, -1703285931, -327559973, -1788065014, 960709480, -1814854069, -908948374, -436117987, 1682085334, -762279866, -183191368, 220080184, -57766241, -676428704, 1598532481, -1255434042, 1989286800, -1717498989, 1784442077, -1337246483, 1458785475, -1332638305, 145755964, -1074151148, 1287376035, 1362332800, 224035916, -23479538, -1409046242, -694125069, -566762324, -630866531, -347269928, 679566165, 276545043, 366390502, 288394184, -1914964681, -1286440751, -2020552257, 1678295557, -443199195, -1935636633, 2101386234, 818513443, -708582396, 1983248498, -1871954656, -161206170, -1859668546, -1151541471, 988479706, -1460631101, 971904816, -1519785494, -1915212800, -1888967964, -1802228876, -1296777115, 1201309406, -1531584106, 826582647, 118055960, -1132107069, -373631934, -1371339394, -1940516137, 1127749479, 1201351105, 68476456, -1744193508, -306861080, -980025384, -2072230927, -1736978617, 1572698384, 1177367976, -1156123924, 775840687, -1727327625, -38219474, -2063183380, -1110362267, 1684813422, -884896557, 1016574566, 803377337, 540645732, -1240017080, -1178332843, 2034593037, 1429295941, 1034344725, 1381736146, -62446596, -833249209, 1611256781, -1200401518, -518501295, 1572749265, -807863775, -746688917, 1656148124, -1201074141, 922162158, 302308805, 2079850451, 1040750617, 2011035759, 1436256879, 344405547, 1340950393, 1207010603, 1972919535, -2062377130, -975191328, -973132685, -1556578693, 931702417, -1990261158, 35115389, -1650124362, 500851691, -1315688156) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite\""} 
[2026-08-14 13:24:54] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, u.name AS usage, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (1705942411) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_usages\" as \"u\" on \"u\".\"id\" = \"em\".\"usage_id\" where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (1411111401, -390568655, -273047452, -366685926, -2129813176, 494216435, -393206791, 562718587, 2001630306, -858228785, 942233085, -1824930634, 1824025864, -35558533, 254468532, 751538419, 1660135024, 1713162907, -1294709678, 97436677, -124660711, 722905366, 579293477, 1140113838, -1419278172, -1982109166, 1409930224, 2117082238, -2034818798, -919487101, -770400240, -1939219148, 155019705, -543242059, 1395794963, 64335092, 692025924, 1184608045, -482664252, 26668268, -2024511393, -289004236, 2113546912, 1924478818, -1270919973, -1865280307, -1323823743, -65650287, -125964541, 556015237, 1890006254, -717879577, 1640238785, -1829002824, 1087885866, 2108532170, 1044726750, -893165577, -1618922050, 1923261691, -2044885611, -2004721785, 1648387281, -731418973, 571578548, -1028097404, 1372013544, -1390684557, 539391017, -2017652732, 632880332, 333711349, 1772504308, -966063115, 28083642, 1477165581, 1900723648, 1253744553, 203783501, 1273925006, 719954458, 1236677003, 689872, 1075533786, -97814566, -337441085, 675577244, -2000350303, 1379603351, 1049700765, 1855887801, 1307996793, 847335499, -14567500, -574407755, -1287483713, -1513139721, 775868583, 1312649538, 1855178673, 660808751, -2044004547, -1581253380, 937605621, -1560607589, -68842748, 682492730, 2005250983, 375123593, -271055130, 1243082219, 1096813866, -1605275342, -704377305, 1079222860, -1837178453, 1663741761, -567757160, 347811431, -980556544, 1553348267, 494206472, 1258750298, -1623725498, -889282158, 1299296056, 2079193929, 423665295, -1749430722, -717359299, -98448292, 1359890860, 1077172953, 392392088, -2017022783, 1184793512, -1869570613, 340061913, 1280935296, 618379975, -1951484904, -469721241, 1842692073, -939991847, 1418466514, 350561514, 1206983340, -337017078, 454621909, 41079158, 1901794668, 1843164580, 1743133853, -1732290900, 1353783048, -858994155, 1054770029, 1528030456, -648559285, -1430328674, 730376509, 223376167, 504001257, -1990228258, -435776990, -2102767552, -933330074, -1614026445, -446796902, -1546313589, 1104829866, 600270447, -323474854, -763786315, 906942419, 283393782, -734407698, -1788065014, 960709480, -2009648112, -1608512036, 489987876, -1814854069, 301093584, 1663410790, 1066750091, 859987309, -1219234331, 220080184, -57766241, -676428704, -1255434042, -964500217, 21511964, 1388087176, -1337246483, 1458785475, -1063238036, -570672305, 224035916, -2145734036, -566762324, -376271361, -347269928, 1519990054, 679566165, 905336003, -1528757905, -2020552257, 50809254, -1935636633, 2101386234, -1316167746, 2001828071, 717533312, -919698739, -1859668546, -1151541471, 988479706, -1888967964, -1802228876, -1296777115, -35163706, 1201309406, -178006637, -1609021450, 425592013, -373631934, -466654990, -22267807, 373557710, -538767368, -583628804, 1231105243, 1035684050, -306861080, -980025384, 530155604, -1878882180, -578878727, -2072230927, 707403387, 595454509, -178885722, 1933574569, -1736978617, 1689971204, 2099170107, -23642967, -1156123924, -1727327625, -2063183380, 1276215965, 1684813422, 932667705, -1240017080, 2034593037, 1381736146, 1911698987, -518501295, -1459018491, 1656148124, -883327242, 1252179801, 1371610371, 2106513667, 1340950393, 1972919535, -2062377130, -975191328, -1981687934, 1764341119, -1414713643, 931702417, -1087220802, -1650124362, 575519546, 500851691) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) and \"em\".\"usage_id\" in (100, 111, 112, 120, 130, 200, 300, 400, 450, 480, 490, 500, 600, 700, 800, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 961, 962, 971, 972, 980, 999, 1001) group by \"em\".\"year_id\", \"territoire\", \"activite\", \"u\".\"name\""} 
[2026-08-14 13:24:54] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, u.name AS usage, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (1705942411) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_usages\" as \"u\" on \"u\".\"id\" = \"em\".\"usage_id\" where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (1411111401, -390568655, -273047452, -366685926, -2129813176, 494216435, -393206791, 562718587, 2001630306, -858228785, 942233085, -1824930634, 1824025864, -35558533, 254468532, 751538419, 1660135024, 1713162907, -1294709678, 97436677, -124660711, 722905366, 579293477, 1140113838, -1419278172, -1982109166, 1409930224, 2117082238, -2034818798, -919487101, -770400240, -1939219148, 155019705, -543242059, 1395794963, 64335092, 692025924, 1184608045, -482664252, 26668268, -2024511393, -289004236, 2113546912, 1924478818, -1270919973, -1865280307, -1323823743, -65650287, -125964541, 556015237, 1890006254, -717879577, 1640238785, -1829002824, 1087885866, 2108532170, 1044726750, -893165577, -1618922050, 1923261691, -2044885611, -2004721785, 1648387281, -731418973, 571578548, -1028097404, 1372013544, -1390684557, 539391017, -2017652732, 632880332, 333711349, 1772504308, -966063115, 28083642, 1477165581, 1900723648, 1253744553, 203783501, 1273925006, 719954458, 1236677003, 689872, 1075533786, -97814566, -337441085, 675577244, -2000350303, 1379603351, 1049700765, 1855887801, 1307996793, 847335499, -14567500, -574407755, -1287483713, -1513139721, 775868583, 1312649538, 1855178673, 660808751, -2044004547, -1581253380, 937605621, -1560607589, -68842748, 682492730, 2005250983, 375123593, -271055130, 1243082219, 1096813866, -1605275342, -704377305, 1079222860, -1837178453, 1663741761, -567757160, 347811431, -980556544, 1553348267, 494206472, 1258750298, -1623725498, -889282158, 1299296056, 2079193929, 423665295, -1749430722, -717359299, -98448292, 1359890860, 1077172953, 392392088, -2017022783, 1184793512, -1869570613, 340061913, 1280935296, 618379975, -1951484904, -469721241, 1842692073, -939991847, 1418466514, 350561514, 1206983340, -337017078, 454621909, 41079158, 1901794668, 1843164580, 1743133853, -1732290900, 1353783048, -858994155, 1054770029, 1528030456, -648559285, -1430328674, 730376509, 223376167, 504001257, -1990228258, -435776990, -2102767552, -933330074, -1614026445, -446796902, -1546313589, 1104829866, 600270447, -323474854, -763786315, 906942419, 283393782, -734407698, -1788065014, 960709480, -2009648112, -1608512036, 489987876, -1814854069, 301093584, 1663410790, 1066750091, 859987309, -1219234331, 220080184, -57766241, -676428704, -1255434042, -964500217, 21511964, 1388087176, -1337246483, 1458785475, -1063238036, -570672305, 224035916, -2145734036, -566762324, -376271361, -347269928, 1519990054, 679566165, 905336003, -1528757905, -2020552257, 50809254, -1935636633, 2101386234, -1316167746, 2001828071, 717533312, -919698739, -1859668546, -1151541471, 988479706, -1888967964, -1802228876, -1296777115, -35163706, 1201309406, -178006637, -1609021450, 425592013, -373631934, -466654990, -22267807, 373557710, -538767368, -583628804, 1231105243, 1035684050, -306861080, -980025384, 530155604, -1878882180, -578878727, -2072230927, 707403387, 595454509, -178885722, 1933574569, -1736978617, 1689971204, 2099170107, -23642967, -1156123924, -1727327625, -2063183380, 1276215965, 1684813422, 932667705, -1240017080, 2034593037, 1381736146, 1911698987, -518501295, -1459018491, 1656148124, -883327242, 1252179801, 1371610371, 2106513667, 1340950393, 1972919535, -2062377130, -975191328, -1981687934, 1764341119, -1414713643, 931702417, -1087220802, -1650124362, 575519546, 500851691) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) and \"em\".\"usage_id\" in (100, 111, 112, 120, 130, 200, 300, 400, 450, 480, 490, 500, 600, 700, 800, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 961, 962, 971, 972, 980, 999, 1001) group by \"em\".\"year_id\", \"territoire\", \"activite\", \"u\".\"name\""} 
[2026-08-14 13:24:58] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite, u.name AS usage, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (1705942411) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_usages\" as \"u\" on \"u\".\"id\" = \"em\".\"usage_id\" where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (1411111401, -390568655, -273047452, -366685926, -2129813176, 494216435, -393206791, 562718587, 2001630306, -858228785, 942233085, -1824930634, 1824025864, -35558533, 254468532, 751538419, 1660135024, 1713162907, -1294709678, 97436677, -124660711, 722905366, 579293477, 1140113838, -1419278172, -1982109166, 1409930224, 2117082238, -2034818798, -919487101, -770400240, -1939219148, 155019705, -543242059, 1395794963, 64335092, 692025924, 1184608045, -482664252, 26668268, -2024511393, -289004236, 2113546912, 1924478818, -1270919973, -1865280307, -1323823743, -65650287, -125964541, 556015237, 1890006254, -717879577, 1640238785, -1829002824, 1087885866, 2108532170, 1044726750, -893165577, -1618922050, 1923261691, -2044885611, -2004721785, 1648387281, -731418973, 571578548, -1028097404, 1372013544, -1390684557, 539391017, -2017652732, 632880332, 333711349, 1772504308, -966063115, 28083642, 1477165581, 1900723648, 1253744553, 203783501, 1273925006, 719954458, 1236677003, 689872, 1075533786, -97814566, -337441085, 675577244, -2000350303, 1379603351, 1049700765, 1855887801, 1307996793, 847335499, -14567500, -574407755, -1287483713, -1513139721, 775868583, 1312649538, 1855178673, 660808751, -2044004547, -1581253380, 937605621, -1560607589, -68842748, 682492730, 2005250983, 375123593, -271055130, 1243082219, 1096813866, -1605275342, -704377305, 1079222860, -1837178453, 1663741761, -567757160, 347811431, -980556544, 1553348267, 494206472, 1258750298, -1623725498, -889282158, 1299296056, 2079193929, 423665295, -1749430722, -717359299, -98448292, 1359890860, 1077172953, 392392088, -2017022783, 1184793512, -1869570613, 340061913, 1280935296, 618379975, -1951484904, -469721241, 1842692073, -939991847, 1418466514, 350561514, 1206983340, -337017078, 454621909, 41079158, 1901794668, 1843164580, 1743133853, -1732290900, 1353783048, -858994155, 1054770029, 1528030456, -648559285, -1430328674, 730376509, 223376167, 504001257, -1990228258, -435776990, -2102767552, -933330074, -1614026445, -446796902, -1546313589, 1104829866, 600270447, -323474854, -763786315, 906942419, 283393782, -734407698, -1788065014, 960709480, -2009648112, -1608512036, 489987876, -1814854069, 301093584, 1663410790, 1066750091, 859987309, -1219234331, 220080184, -57766241, -676428704, -1255434042, -964500217, 21511964, 1388087176, -1337246483, 1458785475, -1063238036, -570672305, 224035916, -2145734036, -566762324, -376271361, -347269928, 1519990054, 679566165, 905336003, -1528757905, -2020552257, 50809254, -1935636633, 2101386234, -1316167746, 2001828071, 717533312, -919698739, -1859668546, -1151541471, 988479706, -1888967964, -1802228876, -1296777115, -35163706, 1201309406, -178006637, -1609021450, 425592013, -373631934, -466654990, -22267807, 373557710, -538767368, -583628804, 1231105243, 1035684050, -306861080, -980025384, 530155604, -1878882180, -578878727, -2072230927, 707403387, 595454509, -178885722, 1933574569, -1736978617, 1689971204, 2099170107, -23642967, -1156123924, -1727327625, -2063183380, 1276215965, 1684813422, 932667705, -1240017080, 2034593037, 1381736146, 1911698987, -518501295, -1459018491, 1656148124, -883327242, 1252179801, 1371610371, 2106513667, 1340950393, 1972919535, -2062377130, -975191328, -1981687934, 1764341119, -1414713643, 931702417, -1087220802, -1650124362, 575519546, 500851691) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) and \"em\".\"usage_id\" in (100, 111, 112, 120, 130, 200, 300, 400, 450, 480, 490, 500, 600, 700, 800, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 961, 962, 971, 972, 980, 999, 1001) group by \"em\".\"year_id\", \"territoire\", \"activite\", \"u\".\"name\""} 
[2026-08-14 13:25:15] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (1705942411) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'snap' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (1411111401, -390568655, -273047452, -366685926, -2129813176, 494216435, -393206791, 562718587, 2001630306, -858228785, 942233085, -1824930634, 1824025864, -35558533, 254468532, 751538419, 1660135024, 1713162907, -1294709678, 97436677, -124660711, 722905366, 579293477, 1140113838, -1419278172, -1982109166, 1409930224, 2117082238, -2034818798, -919487101, -770400240, -1939219148, 155019705, -543242059, 1395794963, 64335092, 692025924, 1184608045, -482664252, 26668268, -2024511393, -289004236, 2113546912, 1924478818, -1270919973, -1865280307, -1323823743, -65650287, -125964541, 556015237, 1890006254, -717879577, 1640238785, -1829002824, 1087885866, 2108532170, 1044726750, -893165577, -1618922050, 1923261691, -2044885611, -2004721785, 1648387281, -731418973, 571578548, -1028097404, 1372013544, -1390684557, 539391017, -2017652732, 632880332, 333711349, 1772504308, -966063115, 28083642, 1477165581, 1900723648, 1253744553, 203783501, 1273925006, 719954458, 1236677003, 689872, 1075533786, -97814566, -337441085, 675577244, -2000350303, 1379603351, 1049700765, 1855887801, 1307996793, 847335499, -14567500, -574407755, -1287483713, -1513139721, 775868583, 1312649538, 1855178673, 660808751, -2044004547, -1581253380, 937605621, -1560607589, -68842748, 682492730, 2005250983, 375123593, -271055130, 1243082219, 1096813866, -1605275342, -704377305, 1079222860, -1837178453, 1663741761, -567757160, 347811431, -980556544, 1553348267, 494206472, 1258750298, -1623725498, -889282158, 1299296056, 2079193929, 423665295, -1749430722, -717359299, -98448292, 1359890860, 1077172953, 392392088, -2017022783, 1184793512, -1869570613, 340061913, 1280935296, 618379975, -1951484904, -469721241, 1842692073, -939991847, 1418466514, 350561514, 1206983340, -337017078, 454621909, 41079158, 1901794668, 1843164580, 1743133853, -1732290900, 1353783048, -858994155, 1054770029, 1528030456, -648559285, -1430328674, 730376509, 223376167, 504001257, -1990228258, -435776990, -2102767552, -933330074, -1614026445, -446796902, -1546313589, 1104829866, 600270447, -323474854, -763786315, 906942419, 283393782, -734407698, -1788065014, 960709480, -2009648112, -1608512036, 489987876, -1814854069, 301093584, 1663410790, 1066750091, 859987309, -1219234331, 220080184, -57766241, -676428704, -1255434042, -964500217, 21511964, 1388087176, -1337246483, 1458785475, -1063238036, -570672305, 224035916, -2145734036, -566762324, -376271361, -347269928, 1519990054, 679566165, 905336003, -1528757905, -2020552257, 50809254, -1935636633, 2101386234, -1316167746, 2001828071, 717533312, -919698739, -1859668546, -1151541471, 988479706, -1888967964, -1802228876, -1296777115, -35163706, 1201309406, -178006637, -1609021450, 425592013, -373631934, -466654990, -22267807, 373557710, -538767368, -583628804, 1231105243, 1035684050, -306861080, -980025384, 530155604, -1878882180, -578878727, -2072230927, 707403387, 595454509, -178885722, 1933574569, -1736978617, 1689971204, 2099170107, -23642967, -1156123924, -1727327625, -2063183380, 1276215965, 1684813422, 932667705, -1240017080, 2034593037, 1381736146, 1911698987, -518501295, -1459018491, 1656148124, -883327242, 1252179801, 1371610371, 2106513667, 1340950393, 1972919535, -2062377130, -975191328, -1981687934, 1764341119, -1414713643, 931702417, -1087220802, -1650124362, 575519546, 500851691) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 13:25:15] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (1705942411) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'snap' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (1411111401, -390568655, -273047452, -366685926, -2129813176, 494216435, -393206791, 562718587, 2001630306, -858228785, 942233085, -1824930634, 1824025864, -35558533, 254468532, 751538419, 1660135024, 1713162907, -1294709678, 97436677, -124660711, 722905366, 579293477, 1140113838, -1419278172, -1982109166, 1409930224, 2117082238, -2034818798, -919487101, -770400240, -1939219148, 155019705, -543242059, 1395794963, 64335092, 692025924, 1184608045, -482664252, 26668268, -2024511393, -289004236, 2113546912, 1924478818, -1270919973, -1865280307, -1323823743, -65650287, -125964541, 556015237, 1890006254, -717879577, 1640238785, -1829002824, 1087885866, 2108532170, 1044726750, -893165577, -1618922050, 1923261691, -2044885611, -2004721785, 1648387281, -731418973, 571578548, -1028097404, 1372013544, -1390684557, 539391017, -2017652732, 632880332, 333711349, 1772504308, -966063115, 28083642, 1477165581, 1900723648, 1253744553, 203783501, 1273925006, 719954458, 1236677003, 689872, 1075533786, -97814566, -337441085, 675577244, -2000350303, 1379603351, 1049700765, 1855887801, 1307996793, 847335499, -14567500, -574407755, -1287483713, -1513139721, 775868583, 1312649538, 1855178673, 660808751, -2044004547, -1581253380, 937605621, -1560607589, -68842748, 682492730, 2005250983, 375123593, -271055130, 1243082219, 1096813866, -1605275342, -704377305, 1079222860, -1837178453, 1663741761, -567757160, 347811431, -980556544, 1553348267, 494206472, 1258750298, -1623725498, -889282158, 1299296056, 2079193929, 423665295, -1749430722, -717359299, -98448292, 1359890860, 1077172953, 392392088, -2017022783, 1184793512, -1869570613, 340061913, 1280935296, 618379975, -1951484904, -469721241, 1842692073, -939991847, 1418466514, 350561514, 1206983340, -337017078, 454621909, 41079158, 1901794668, 1843164580, 1743133853, -1732290900, 1353783048, -858994155, 1054770029, 1528030456, -648559285, -1430328674, 730376509, 223376167, 504001257, -1990228258, -435776990, -2102767552, -933330074, -1614026445, -446796902, -1546313589, 1104829866, 600270447, -323474854, -763786315, 906942419, 283393782, -734407698, -1788065014, 960709480, -2009648112, -1608512036, 489987876, -1814854069, 301093584, 1663410790, 1066750091, 859987309, -1219234331, 220080184, -57766241, -676428704, -1255434042, -964500217, 21511964, 1388087176, -1337246483, 1458785475, -1063238036, -570672305, 224035916, -2145734036, -566762324, -376271361, -347269928, 1519990054, 679566165, 905336003, -1528757905, -2020552257, 50809254, -1935636633, 2101386234, -1316167746, 2001828071, 717533312, -919698739, -1859668546, -1151541471, 988479706, -1888967964, -1802228876, -1296777115, -35163706, 1201309406, -178006637, -1609021450, 425592013, -373631934, -466654990, -22267807, 373557710, -538767368, -583628804, 1231105243, 1035684050, -306861080, -980025384, 530155604, -1878882180, -578878727, -2072230927, 707403387, 595454509, -178885722, 1933574569, -1736978617, 1689971204, 2099170107, -23642967, -1156123924, -1727327625, -2063183380, 1276215965, 1684813422, 932667705, -1240017080, 2034593037, 1381736146, 1911698987, -518501295, -1459018491, 1656148124, -883327242, 1252179801, 1371610371, 2106513667, 1340950393, 1972919535, -2062377130, -975191328, -1981687934, 1764341119, -1414713643, 931702417, -1087220802, -1650124362, 575519546, 500851691) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
[2026-08-14 13:25:17] local.DEBUG: EmissionQueryBuilder {"context":"App\\Services\\Inventaire\\{closure}","mode":"agg","source_table":"observatoire.agg_petr","filter_level":"petr","display_level":null,"years":[2024],"sql":"select em.year_id, COALESCE(t.name, '(non rattaché)') AS territoire, COALESCE(a.name, '(non rattaché)') AS activite_parent, COALESCE(a_display.name, '(non rattaché)') AS activite, ROUND(SUM(em.covnm_kg)::numeric, 4) AS covnm_kg from \"observatoire\".\"agg_petr\" as \"em\" left join \"observatoire\".\"dim_territories\" as \"t\" on \"t\".\"id\" = \"em\".\"geo_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a\" on \"dtm_a\".\"activity_id\" = \"em\".\"activity_id\" and \"dtm_a\".\"parent_id\" in (1705942411) inner join \"observatoire\".\"dim_activities\" as \"a\" on \"a\".\"id\" = \"dtm_a\".\"parent_id\" inner join \"observatoire\".\"dim_activity_memberships\" as \"dtm_a_display\" on \"dtm_a_display\".\"activity_id\" = \"em\".\"activity_id\" inner join \"observatoire\".\"dim_activities\" as \"a_display\" on \"a_display\".\"id\" = \"dtm_a_display\".\"parent_id\" and \"a_display\".\"type_id\" = 'snap' where \"em\".\"year_id\" in (2024) and \"em\".\"geo_id\" in (-1339322508) and \"em\".\"activity_id\" in (1411111401, -390568655, -273047452, -366685926, -2129813176, 494216435, -393206791, 562718587, 2001630306, -858228785, 942233085, -1824930634, 1824025864, -35558533, 254468532, 751538419, 1660135024, 1713162907, -1294709678, 97436677, -124660711, 722905366, 579293477, 1140113838, -1419278172, -1982109166, 1409930224, 2117082238, -2034818798, -919487101, -770400240, -1939219148, 155019705, -543242059, 1395794963, 64335092, 692025924, 1184608045, -482664252, 26668268, -2024511393, -289004236, 2113546912, 1924478818, -1270919973, -1865280307, -1323823743, -65650287, -125964541, 556015237, 1890006254, -717879577, 1640238785, -1829002824, 1087885866, 2108532170, 1044726750, -893165577, -1618922050, 1923261691, -2044885611, -2004721785, 1648387281, -731418973, 571578548, -1028097404, 1372013544, -1390684557, 539391017, -2017652732, 632880332, 333711349, 1772504308, -966063115, 28083642, 1477165581, 1900723648, 1253744553, 203783501, 1273925006, 719954458, 1236677003, 689872, 1075533786, -97814566, -337441085, 675577244, -2000350303, 1379603351, 1049700765, 1855887801, 1307996793, 847335499, -14567500, -574407755, -1287483713, -1513139721, 775868583, 1312649538, 1855178673, 660808751, -2044004547, -1581253380, 937605621, -1560607589, -68842748, 682492730, 2005250983, 375123593, -271055130, 1243082219, 1096813866, -1605275342, -704377305, 1079222860, -1837178453, 1663741761, -567757160, 347811431, -980556544, 1553348267, 494206472, 1258750298, -1623725498, -889282158, 1299296056, 2079193929, 423665295, -1749430722, -717359299, -98448292, 1359890860, 1077172953, 392392088, -2017022783, 1184793512, -1869570613, 340061913, 1280935296, 618379975, -1951484904, -469721241, 1842692073, -939991847, 1418466514, 350561514, 1206983340, -337017078, 454621909, 41079158, 1901794668, 1843164580, 1743133853, -1732290900, 1353783048, -858994155, 1054770029, 1528030456, -648559285, -1430328674, 730376509, 223376167, 504001257, -1990228258, -435776990, -2102767552, -933330074, -1614026445, -446796902, -1546313589, 1104829866, 600270447, -323474854, -763786315, 906942419, 283393782, -734407698, -1788065014, 960709480, -2009648112, -1608512036, 489987876, -1814854069, 301093584, 1663410790, 1066750091, 859987309, -1219234331, 220080184, -57766241, -676428704, -1255434042, -964500217, 21511964, 1388087176, -1337246483, 1458785475, -1063238036, -570672305, 224035916, -2145734036, -566762324, -376271361, -347269928, 1519990054, 679566165, 905336003, -1528757905, -2020552257, 50809254, -1935636633, 2101386234, -1316167746, 2001828071, 717533312, -919698739, -1859668546, -1151541471, 988479706, -1888967964, -1802228876, -1296777115, -35163706, 1201309406, -178006637, -1609021450, 425592013, -373631934, -466654990, -22267807, 373557710, -538767368, -583628804, 1231105243, 1035684050, -306861080, -980025384, 530155604, -1878882180, -578878727, -2072230927, 707403387, 595454509, -178885722, 1933574569, -1736978617, 1689971204, 2099170107, -23642967, -1156123924, -1727327625, -2063183380, 1276215965, 1684813422, 932667705, -1240017080, 2034593037, 1381736146, 1911698987, -518501295, -1459018491, 1656148124, -883327242, 1252179801, 1371610371, 2106513667, 1340950393, 1972919535, -2062377130, -975191328, -1981687934, 1764341119, -1414713643, 931702417, -1087220802, -1650124362, 575519546, 500851691) and \"em\".\"activity_id\" not in (-1961301967, 1409433884, -480772070, 253605083, -1464052776, -290906344, -1845071579, 1744461479, -1645028903, -990500766, 454426900, 1145100677, -1320427570, 1885478838, 1588799712, 1741583917) group by \"em\".\"year_id\", \"territoire\", \"activite_parent\", \"activite\""} 
