-1

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;```
  • Please add table definitions for coviddeaths and covidvaccinations together with sample data as text. – P.Salmon Jul 25 '22 at 06:36

3 Answers3

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)
  • 1
    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? – aassss111 Jul 25 '22 at 04:03
0

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

yusuf
  • 1
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34168142) – Standin.Wolf Apr 10 '23 at 20:42
  • 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](/help/how-to-answer). – Community Apr 11 '23 at 12:17
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
KPC
  • 57
  • 1
  • 5