Skip to content

Commit

Permalink
Merge pull request #766 from MTES-MCT/fix-sum-percent
Browse files Browse the repository at this point in the history
Fix sum percent
  • Loading branch information
alexisig authored Nov 28, 2024
2 parents 2645c19 + 0e69dba commit 1b81314
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions airflow/include/sql/sparte/macros/utils/sum_percent.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
sum({{ field }}) as {{ field }},
( -- prevents division by zero
CASE
WHEN sum({{ total_field }}) = 0 THEN sum({{ field }}) * 100 / 1
ELSE sum({{ field }}) * 100 / sum({{ total_field }})
WHEN max({{ total_field }}) = 0 THEN sum({{ field }}) * 100 / 1
ELSE sum({{ field }}) * 100 / max({{ total_field }})
END
) as {{ field }}_percent
{% endmacro %}

0 comments on commit 1b81314

Please sign in to comment.