name 國家名 | continent 洲份 | area 面積 | population 人口 | gdp 國民生產總值 |
---|---|---|---|---|
Afghanistan | Asia | 652230 | 25500100 | 20343000000 |
Albania | Europe | 28748 | 2831741 | 12960000000 |
Algeria | Africa | 2381741 | 37100000 | 188681000000 |
Andorra | Europe | 468 | 78115 | 3712000000 |
Angola | Africa | 1246700 | 20609294 | 100990000000 |
... |
1. 列出每個國家的名字 name, 當中人口 population 是高於俄羅斯'Russia'的人口.
- SELECT name FROM world
- WHERE population>
- (SELECT population FROM world
- WHERE name='Russia')
2. 列出歐州每國家的人均 GDP, 當中人均 GDP 要高於英國'United Kingdom'的數值.
- select name from world
- where gdp/population> (select gdp/population from world where name ='united kingdom') and continent ='Europe'
3. 在阿根廷 Argentina 及 澳大利亞 Australia 所在的洲份中, 列出當中的國家名字 name 及洲分 continent . 按國字名字順序排序
- select name,continent from world
- where continent in('South America','Oceania')
- order by name asc
4. 哪一個國家的人口比加拿大 Canada 的多, 但比波蘭 Poland 的少? 列出國家名字 name 和人口 population .
- select name,population from world
- where population<(select population from world where name='poland') and population>(select population from world where name='canada')
5.Germany 德國 (人口 8000 萬), 在 Europe 歐洲國家的人口最多. Austria 奧地利(人口 850 萬) 擁有德國總人口的 11%.
顯示歐洲的國家名稱 name 和每個國家的人口 population. 以德國的人口的百分比作人口顯示.
(暂时不会)
6. 哪些國家的 GDP 比 Europe 歐洲的全部國家都要高呢? [只需列出 name .] (有些國家的記錄中, GDP 是 NULL, 沒有填入資料的.)
- select name from world
- where gdp>all(select gdp from world where continent='europe'and gdp>0)
7. 在每一個州中找出最大面積的國家, 列出洲份 continent, 國家名字 name 及面積 area. (有些國家的記錄中, AREA 是 NULL, 沒有填入資料的.)
- SELECT continent, name, area FROM world x
- WHERE area>= ALL
- (SELECT area FROM world y
- WHERE y.continent=x.continent
- AND area>0)
8. 列出洲份名稱, 和每個洲份中國家名字按子母順序是排首位的國家名.(即每洲只有列一國)
(暂时不会)
来源: http://www.bubuko.com/infodetail-3563416.html