Last active
August 31, 2020 23:21
-
-
Save djouallah/2a33af59d23e3ccd065a2d1f8d707958 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with tt as (SELECT gg.countries_and_territories as Countries , date, sum( daily_deaths ) as daily_deaths ,max(pop) as pop FROM `GIS.covid19new` gg | |
left join (SELECT countries_and_territories,max( pop_data_2019) as pop FROM `GIS.covid19new` group by 1) pp | |
on gg.countries_and_territories =pp.countries_and_territories | |
where gg.countries_and_territories in unnest(@selection) group by 1,2 | |
UNION ALL | |
SELECT "Rest of the World" as Countries , date,sum( daily_deaths ) as daily_deaths,sum(pop ) FROM `GIS.covid19new` gg | |
left join (SELECT countries_and_territories,max( pop_data_2019) as pop FROM `GIS.covid19new` group by 1) pp | |
on gg.countries_and_territories =pp.countries_and_territories | |
where gg.countries_and_territories not in unnest(@selection) group by 1,2) | |
select *, sum(daily_deaths) over(partition by Countries order by date) as daily_deaths_cumulative from tt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment