时间:2021-07-01 10:21:17 帮助过:90人阅读
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‘的人口。
- <span style="font-size: 16px;">SELECT name FROM world
- WHERE population >
- (SELECT population FROM world
- WHERE name=‘Russia‘)
- </span>
2.列出歐州每國家的人均GDP,當中人均GDP要高於英國‘United Kingdom‘的數值。
- <span style="font-size: 16px;">select name from world
- where gdp/population > (select gdp/population from world where name =‘united kingdom‘) and continent =‘Europe‘
- </span>
3.在阿根廷Argentina 及 澳大利亞 Australia所在的洲份中,列出當中的國家名字 name 及洲分 continent 。按國字名字順序排序
- <span style="font-size: 16px;">select name,continent from world
- where continent in(‘South America‘,‘Oceania‘)
- order by name asc
- </span>
4.哪一個國家的人口比加拿大Canada的多,但比波蘭Poland的少?列出國家名字name和人口population 。
- <span style="font-size: 16px;">select name,population from world
- where population<(select population from world where name=‘poland‘) and population >(select population from world where name=‘canada‘)
- </span>
5.Germany德國(人口8000萬),在Europe歐洲國家的人口最多。Austria奧地利(人口850萬)擁有德國總人口的11%。
顯示歐洲的國家名稱name和每個國家的人口population。以德國的人口的百分比作人口顯示。
(暂时不会)
6.哪些國家的GDP比Europe歐洲的全部國家都要高呢? [只需列出 name 。] (有些國家的記錄中,GDP是NULL,沒有填入資料的。)
- <span style="font-size: 16px;">select name from world
- where gdp >all(select gdp from world where continent=‘europe‘and gdp>0)
- </span>
7.在每一個州中找出最大面積的國家,列出洲份 continent, 國家名字 name 及面積 area。 (有些國家的記錄中,AREA是NULL,沒有填入資料的。)
- <span style="font-size: 16px;">SELECT continent, name, area FROM world x
- WHERE area >= ALL
- (SELECT area FROM world y
- WHERE y.continent=x.continent
- AND area>0)
- </span>
8.列出洲份名稱,和每個洲份中國家名字按子母順序是排首位的國家名。(即每洲只有列一國)
(暂时不会)
SQL练习-SQLZOO SQLZOO:SELECT within SELECT Tutorial
标签:body man tin bsp sele 最大 with tab nbsp