注册 登录
编程论坛 SQL Server论坛

请高手帮忙看几个程序

anxiaonong 发布于 2009-07-25 22:17, 525 次点击
程序要求是查询出能满足世界GDP 总量一半的必要的人口数量,但是里面很多select from(select from 结构,请问怎么理解?另外 t1,t2,t3,t4代表什么?

程序如下:
select sum(population) from
(select t1.name, t1.efficiency,t1.population,t1.gdp,(select sum(gdp) from
                                                                    (select name,gdp/c2.population as efficiency,population,gdp
                                                                     from country c2, economy e2
                                                                     where c2.code = e2.country and e2.gdp is not null
                                                                     order by efficiency desc) t2
                                                   
where t2.efficiency >= t1.efficiency) as total
from
    (select name,gdp/c1.population as efficiency,population,gdp
     from country c1, economy e1
     where c1.code = e1.country and e1.gdp is not null
     order by efficiency desc)  t1)t3,
(select sum(gdp)/2 as gdp_50 from economy) t4
where total <= gdp_50
0 回复
1