首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

高分-求疑难SQL语句解决思路

2012-01-31 
高分-求疑难SQL语句表bbc有以下字段name(国家名字),region(种族),area(所在区域),population(人口)问题:显

高分-求疑难SQL语句
表bbc有以下字段
name(国家名字),   region(种族),   area(所在区域),   population(人口)
问题:
显示一个国家和它所属的地区名字,这个国家的人口比同一个地区内的任何一个国家的人口的三倍还要多  



[解决办法]
select
name, area
from bbc a
where not exists(
select * from bbc
where area = a.area
and name <> a.name
and population * 3 < a.population)

[解决办法]
declare
@p int
select @p=population*3 from bbc

select name,area from bbc B where population> @p and area=B.area

热点排行