在oracle中,提出问题
哪个国家的人口超过加拿大但低于波兰?显示名称和人口
我这样做了。
select name,population from world
where population > (select population from world where name='Canada')
and population< (select population from world where name ='Poland')
还有其他优化方式吗?
答案 0 :(得分:0)
这样的东西?
WITH can_pol
AS (SELECT SUM (DECODE (name, 'Canada', population)) pop_can,
SUM (DECODE (name, 'Poland', population)) pop_pol
FROM world)
SELECT name, population
FROM world, can_pol
WHERE population > pop_can
AND population < pop_pol;