-1

I am getting an error when trying to run the code below. I have tried almost everyting and have no idea why it's wrong. Can you please have a look at that?

Create Table #PercentPopulationVaccinated
(
continent nvarchar(255),
Location nvarchar(255),
Date datetime,
Population numeric,
New_vaccinations numeric,
RollingPeopleVaccinated numeric
)

Insert into #PercentPopulationVaccinated
select dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations
, sum(convert(bigint,vac.new_vaccinations)) OVER (Partition by dea.Location order by dea.location, dea.date) as RollingPeopleVaccinated
from PortfolioProject..CovidDeaths dea
join PortfolioProject..CovidVaccinations vac 
    on  dea.location = vac.location
    and dea.date = vac.date
where dea.continent is not null

Select *, (RollingPeopleVaccinated/population)*100
From #PercentPopulationVaccinated
  • Why do you want to copy data between tables? Such copying too often leads to data inconsistency. Consider creating a view instead. – jarlh Oct 11 '22 at 11:39

1 Answers1

0
Insert into #PercentPopulationVaccinated(continent,location,
date,population,New_vaccinations,RollingPeopleVaccinated )
select dea.continent, dea.location, 
dea.date, dea.population, vac.new_vaccinations,
sum(convert(bigint,vac.new_vaccinations)) OVER (Partition by dea.Location order by dea.location, dea.date) 
 from PortfolioProject..CovidDeaths dea
 join PortfolioProject..CovidVaccinations vac 
  on  dea.location = vac.location
  and dea.date = vac.date
where dea.continent is not null
Sergey
  • 4,719
  • 1
  • 6
  • 11