Drop table if exists #populationpercentagevaccine
Create Table #populationpercentagevaccine
(
Continent nvarchar(255),
location nvarchar(255),
Date Datetime,
Population numeric,
New_vaccinations numeric,
cumulative_vaccine numeric
)
我的表执行完美,但代码INSERT INTO给我麻烦
Insert into #populationpercentagevaccine
select death.Continent, death.location, death.Date, death.Population, vaccine.New_vaccinations,
sum(convert(int,vaccine.new_vaccinations )) over(partition by death.location order by death.location, death.date) as cumulative_all_vaccine
我创建了一个表,并在同一个表中插入了导致列名或提供的值的数量与表定义不匹配的原因这个问题
您的表列和插入时提供的列不匹配。
Insert into #populationpercentagevaccine
select Continent, [location], [Date], [Population], New_vaccinations
, sum(convert(int,new_vaccinations )) over(partition by [location] order by [location, [date]) as cumulative_all_vaccine
from #populationpercentagevaccine
这是你之前的问题:
Create Table #populationpercentagevaccine
(
Continent nvarchar(255),
location nvarchar(255),
Date Datetime,
Population numeric,
New_vaccinations numeric,
cumulative_vaccine numeric,
cumulative_all_vaccine numeric
)
Insert into #populationpercentagevaccine
select Continent, [location], [Date], [Population], New_vaccinations, cumulative_vaccine --this was missing earlier
, sum(convert(int,new_vaccinations )) over(partition by [location]
order by [location, [date]) as cumulative_all_vaccine
from #populationpercentagevaccine
您的表有7列,您的查询仅为其中6列提供值。要么提供值,要么插入标识符