chris finn
chris finn

Reputation: 13

How to insert decimal point and round using SQL

Data set is from https://sqlzoo.net/wiki/SELECT_from_WORLD_Tutorial, number 9

I am using

SELECT name, ROUND(population, 3,0), ROUND(GDP, 3,0)
FROM world
WHERE continent = 'South America' 

Answer should be

name        
Argentina   42.67   477.03
Bolivia 10.03   27.04
Brazil  202.79  2254.11

I am getting

name        
Argentina   42669500    477028000000
Bolivia 10027254    27035000000
Brazil  202794000   2254109000000

...

Upvotes: 0

Views: 133

Answers (1)

GMB
GMB

Reputation: 222482

You want the population in millions and GDP in billions, both rounded to two decimals. Consider:

SELECT name, ROUND(population/1000000, 2), ROUND(GDP/1000000000, 2)
FROM world
WHERE continent = 'South America' 

Upvotes: 2

Related Questions