Show the name and per-capita GDP for those countries with a GDP of at least one trillion (1000000000000; that is 12 zeros). Round this value to the nearest 1000. Show per-capita GDP for the trillion dollar countries to the nearest $1000.
SELECT name ,
ROUND(gdp/population,0.01)
from world
where gdp >= 1000000000000
但这会产生错误。
任务可测试here
最佳答案
round 的第二个参数是小数点之后或之前的位数。我会从以下开始:
select name ,
ROUND(gdp/population, -3)
from world
where gdp >= 1000000000000
负数位于小数点之前。您可以阅读documentation .
关于mysql - 带 ROUND 和除法的 sql 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46931811/