Skip to content

Commit

Permalink
feat(pop): add percent
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisig committed Nov 14, 2024
1 parent aa83919 commit 0afd00a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ SELECT
last_available_year=2020
) %}
sum(population_{{ start_year }}_{{ end_year + 1 }})
as population_{{ start_year }}_{{ end_year + 1 }}
as population_{{ start_year }}_{{ end_year + 1 }},
sum(population_{{ start_year }}_{{ end_year + 1 }}) * 100 / sum(population_{{ start_year }})
as population_{{ start_year }}_{{ end_year + 1 }}_percent
{% endcall %}
FROM
{{ ref('flux_population') }} as flux_population
Expand Down
15 changes: 14 additions & 1 deletion airflow/include/sql/sparte/models/insee/flux_population.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}}
with flux as (
SELECT
code_commune,
*, -- keep stock columns
(population_2010 - population_2009) as population_2009_2010,
(population_2011 - population_2010) as population_2010_2011,
(population_2012 - population_2011) as population_2011_2012,
Expand All @@ -24,6 +24,19 @@ with flux as (
)
SELECT
code_commune,
population_2009,
population_2010,
population_2011,
population_2012,
population_2013,
population_2014,
population_2015,
population_2016,
population_2017,
population_2018,
population_2019,
population_2020,
population_2021,
{% call(start_year, end_year) cumulative_flux(
first_available_year=2009,
last_available_year=2020
Expand Down

0 comments on commit 0afd00a

Please sign in to comment.