0

I got error code 1292 from this code Can you let me know how to fix it?

I am just trying to make temp table

create table percentpopulationvaccinated (
continent varchar(255),
location varchar(255),
date datetime,
population numeric,
new_vaccinations numeric,
People_Vaccinated numeric
);

Insert into percentpopulationvaccinated
Select death.continent, death.location, death.date, death.population, vac.new_vaccinations, 
sum(convert(vac.new_vaccinations, signed int)) over (partition by death.location order by death.location, death.date) as People_Vaccinated
from coviddeaths as death
join covidvaccinations as vac
    on death.location = vac.location
    and death.date = vac.date;
-- where death.continent is not null
-- order by death.location, death.date

select *, (People_Vaccinated/population)*100
from percentpopulationvaccinated;```
1
  • Please add table definitions for coviddeaths and covidvaccinations together with sample data as text. Commented Jul 25, 2022 at 6:36

3 Answers 3

0

See this answer: Truncated incorrect INTEGER value

It's not an error. It's a warning that comes from CONVERT() when you ask it to convert non-numeric to integer;

convert(vac.new_vaccinations, signed int)
Sign up to request clarification or add additional context in comments.

1 Comment

But I still get no result when I run select *, (People_Vaccinated/population)*100 from percentpopulationvaccinated; can you let me know how to fix it to see the result?
0

Maybe This will help you. use '(int)' before the variable value (like (int)new_vaccinations) for solve this error.

2 Comments

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
0

I solved this issue using NULLIF to replace '' with NULL.

NULLIF(floor(cv.new_vaccinations), '') as new_vaccinations
sum(NULLIF(cv.new_vaccinations, '')) over (partition by cd.location order by cd.location, cd.date) as RollingPeopleVaccinated

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.