Drop table if exists #populationpercentagevaccine
Create Table #populationpercentagevaccine
(
Continent nvarchar(255),
location nvarchar(255),
Date Datetime,
Population numeric,
New_vaccinations numeric,
cumulative_vaccine numeric
)
My table is executing perfect but that code INSERT INTO giving me problem
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
I created table and inserting into that same table what is causing Column name or number of supplied values does not match table definition that problem
CodePudding user response:
Your table columns and supplied columns in insert was not matching earlier.
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
This was your previous question:
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
CodePudding user response:
your table has 7 columns, your query supplies values only for 6 of them. either supply the value or insert the identity