sql句子,一道英文题目,欢迎大家讨论

teamax 2007-04-22 07:51:13
有如下表
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.


题目的要求是求国家的名字(也就是比它同地区大三倍人口的国家)和地区,我想搞复杂点,能不能有个句子把另外一个国家的名字也输出.也就是(国家,国家,地区)

...全文
217 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
teamax 2007-04-26
  • 打赏
  • 举报
回复
也就是说第一个国家的人口比第二个国家大三倍嘛,另外一个国家就是第二个国家嘛,了解不
hxp9118 2007-04-23
  • 打赏
  • 举报
回复
写错了,更正一下。
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)
hxp9118 2007-04-23
  • 打赏
  • 举报
回复
select country, region, population
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))
lang8134 2007-04-23
  • 打赏
  • 举报
回复
没能理解楼主题目中,“另外一个国家”指的什么?
hxp9118 2007-04-23
  • 打赏
  • 举报
回复
理解错误。。。呵呵。再贴一个。哈哈
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 上调过。没问题。
laochake 2007-04-22
  • 打赏
  • 举报
回复
select b1.name, b2.name, b1.area
from bbc b1
join bbc b2 on b1.area=b2.area
where b1.population>b2.population*3

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧