有如下表
bbc(name, region, area, population, gdp)
表的内容省略,反正就是国家,地区,面积,人口,国内生产总值
题目要求:
Some countries have populations more than three times that of any of their neighbours (in the same region). Give the countries and regions.
题目的要求是求国家的名字(也就是比它同地区大三倍人口的国家)和地区,我想搞复杂点,能不能有个句子把另外一个国家的名字也输出.也就是(国家,国家,地区)
bbc(name, region, area, population, gdp)
表的内容省略,反正就是国家,地区,面积,人口,国内生产总值
题目要求:
Some countries have populations more than three times that of any of their neighbours (in the same region). Give the countries and regions.
题目的要求是求国家的名字(也就是比它同地区大三倍人口的国家)和地区,我想搞复杂点,能不能有个句子把另外一个国家的名字也输出.也就是(国家,国家,地区)
from bbc b1
join bbc b2 on b1.area=b2.area
where b1.population>b2.population*3
from bbc a
where (select top 1 population from bbc b where b.region=a.region and b.population >3*(select top 1 population from bbc c where c.region=a.region and c.country<> a.country))
select country, region, population
from bbc a
where a.population >3*(select top 1 population from bbc b where b.region=a.region and b.country<> a.country)
select a.country, b.country, a.population from bbc a, bbc b where a.region=b.region and a.country<> b.country and
a.population >3*(select top 1 population from bbc c where c.region=a.region and c.country<> a.country)
在sql server 2000 上调过。没问题。