I created a temp table and insert into
a subquery but I got an error saying ‘syntax error at or near “INSERT”‘. Can anyone have idea? Thanks!
CREATE TABLE population_vaccinated2 ( continent VARCHAR(200), location VARCHAR(200), date DATE, population INT, new_vaccinations NUMERIC, aggre_vaccinations NUMERIC ) INSERT INTO population_vaccinated2 SELECT dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations, SUM(vac.new_vaccinations) OVER (PARTITION BY dea.location ORDER BY dea.location, dea.date) AS aggre_vaccinations FROM covid_deaths AS dea JOIN covid_vaccinations AS vac ON dea.location = vac.location AND dea.date = vac.date
Advertisement
Answer
Note that CREATE TABLE
and INSERT INTO
are two distinct statements. You need to insert a ;
between them:
... ) ; INSERT INTO ...
I created a temp table
Note that this is not a temporary table because you are missing the TEMPORARY
keyword.