I have a query where in I divide 2 columns and multiply it by 100 in a new column(DeathPercentage). But this new column data type is automatically set into bigint, is there a way that i could change it to decimal?
SELECT location, total_deaths, population.population, (total_deaths/population.population)*100 as DeathPercentage FROM covid_deaths
LEFT OUTER JOIN population
ON covid_deaths.location = population.country
WHERE covid_deaths.continent !='null'
3
Answers
I don’t know if your language have this, but Java have something call casting. That might work for your language!
Postgres has
cast
, 2 versions. In this case you can:The first using the SQL standard and the second a Postgres extension.