首页 > 解决方案 > 语法错误:预期输入结束,但在 bigquery 中的 [11:1] 处出现关键字 INSERT 错误

问题描述

语法错误:预期输入结束,但在 bigquery 中的 [11:1] 处出现关键字 INSERT 错误

create table percentpopulationvaccinated
(
    continent string,
    Location string,
    Date datetime,
    population numeric,
    new_vaccinations numeric,
    peoplevaccinated numeric
)

insert into percentpopulationvaccinated 
    select 
        dea.continent, dea.location, dea.date, dea.population,  
        new_vaccinations,
        sum(vac.new_vaccinations) over (partition by dea.location order by dea.location, dea.date) as peoplevaccinated
    from 
        my-protfolio-324718.sql_code.covid_deaths dea
    join 
        my-protfolio-324718.sql_code.covid_vac vac on dea.location = vac.location
                                                   and dea.date = vac.date

select 
    *,
    (peoplevaccinated / population) * 100
from 
    percentpopulationvaccinated

标签: sqlgoogle-bigquery

解决方案


create table 是一个查询,insert into 是第二个,最后第三个是 select。在 bigquery 中,您应该使用 a 将它们分开,;以便解释器可以按顺序运行每一步。


推荐阅读