【问题标题】:Syntax error: Expected end of input but got keyword INSERT at [11:1] error in bigquery语法错误:预期输入结束,但在 bigquery 中的 [11:1] 处出现关键字 INSERT 错误
【发布时间】:2021-09-01 21:29:35
【问题描述】:

语法错误:预期输入结束,但在 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

【问题讨论】:

  • 您有一个包含两个语句(创建和插入)的脚本。所有语句都必须用 ; 分隔,所以在 insert 和前面的 ) 之间添加它,你应该没问题,直到可能出现下一个/另一个错误:o)

标签: sql google-bigquery


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多