我想打印以下结果
Oceania 109189
South America 147435
Europe 175138
Africa 274439
Asia 693038
我的查询是
select co.Continent bb, round(avg(ci.Population)) as aa
from Country co
FULL OUTER JOIN City ci ON co.Code = ci.CountryCode
group by co.Continent
having (count(ci.ID)<>0 and co.Continent is not null)
order by aa asc;
并显示以下结果
Africa 274439
Asia 693038
Europe 175138
Oceania 109190
South America 147435
如何使用舍入值????
订购结果答案 0 :(得分:0)
尝试以下,
select bb, round(aa) as aa from (
select co.Continent bb, avg(ci.Population) as aa
from Country co
FULL OUTER JOIN City ci ON co.Code = ci.CountryCode
group by co.Continent
having (count(ci.ID)<>0 and co.Continent is not null)
)T
order by round(aa);
答案 1 :(得分:0)
我认为没有理由为什么ORDER BY不起作用。您的查询是正确的。显然,你得到了co.Continent订购的唱片。
因此,在从DBMS获取结果后,您的应用必须执行此类操作。可能是自动排序列表框等吗?
答案 2 :(得分:0)
这不是简单的工作吗? :
select co.continent bb, round (avg (ci.population)) as aa
from country co full outer join city ci on co.code = ci.countrycode
group by co.continent
having (count (ci.id) <> 0 and co.continent is not null)
order by round (avg (ci.population)) asc;