This is a screenshot of some data. I'm trying to calculate the DeathPercentage
with the following script.
SELECT
location, date, total_cases,total_deaths,
((total_deaths / total_cases) * 100) AS DeathPercentage
FROM
CovidDeaths_csv cdc
CodePudding user response:
total_deaths
and total_cases
are integers, and you are calculating the integer ratio. As deaths < cases, deaths/cases = 0. Try ((total_deaths*1.0/total_cases)*100)
.