gpt4 book ai didi

mysql - 带 ROUND 和除法的 sql 查询

转载 作者:行者123 更新时间:2023-11-29 10:33:34 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com