with pop_vs_vac (dea.continent, location, date, population, new_vaccinations, rolling_people_vaccinated) as (
Select dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations, SUM(CASt(vac.new_vaccinations as int)) OVER (partition by dea.location order by dea.location, dea.date) as rolling_peoploe_vaccinated, --(rollling_people_vaccinated/population)* 100
from gg-analytics-404715.Portfolio_Covid.Covid_Deaths
as dea
join gg-analytics-404715.Portfolio_Covid.Covid_vaccinations
as vac
on dea.location = vac.location
and dea.date = vac.date
where dea.continent is not null
--- order by 1, 2, 3
)
select *
from pop_vs_vac
;with pop_vs_vac (continent, location, date, population, new_vaccinations, rolling_people_vaccinated) as (
Select dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations, SUM(CASt(vac.new_vaccinations as int)) OVER (partition by dea.location order by dea.location, dea.date) as rolling_peoploe_vaccinated --(rollling_people_vaccinated/population)* 100
from [gg-analytics-404715.Portfolio_Covid.Covid_Deaths] as dea
join [gg-analytics-404715.Portfolio_Covid.Covid_vaccinations] as vac
on dea.location = vac.location
and dea.date = vac.date
where dea.continent is not null
--- order by 1, 2, 3
)
select *
from pop_vs_vac
It still did not work it BigQuerry Sandbox still says ERROR: Expected keyword AS but got "(" at [1:17]
This is a SQL Server forum. I don't know any syntax for BigQuery.
It appears BigQuery may not support supplying a column list with a CTE, so instead use:
WITH pop_vs_vac AS
( SELECT dea.continent, ...