1.列出每個國家的名字 name,當中人口 population 是高於俄羅斯’Russia’的人口。
1. SELECT name
2. FROM world
3. WHERE population >
4. (SELECT population FROM world WHERE name='Russia');
2.列出歐州每國家的人均GDP,當中人均GDP要高於英國’United Kingdom’的數值。
1. select name
2. from world
3. where gdp/population>(select gdp/population
4. from world
5. where name='United Kingdom')
6. and continent='Europe';
3.在阿根廷Argentina 及 澳大利亞 Australia所在的洲份中,列出當中的國家名字 name 及洲分 continent 。按國字名字順序排序
1. select name,continent
2. from world
3. where continent in (select continent
4. from world
5. where name='Argentina' or name='Australia')
6. order by name;
4.哪一個國家的人口比加拿大Canada的多,但比波蘭Poland的少?列出國家名字name和人口population 。
1. select name,population
2. from world
3. where population > (select population
4. from world
5. where name='Canada') and population < (select population
6. from world
7. where name='Poland')
5.Germany德國(人口8000萬),在Europe歐洲國家的人口最多。Austria奧地利(人口850萬)擁有德國總人口的11%。
顯示歐洲的國家名稱name和每個國家的人口population。以德國的人口的百分比作人口顯示。
#此题没有得到小笑脸,答案跟网上找的一样,但是不知道为啥没得到小笑脸。留着以后有空再看看怎## 标题么调试。
1. select name,concat(round(population/(select population
2. from world
3. where name='Germany')*100,0),'%')
4. from world
5. where continent='Europe';
6.哪些國家的GDP比Europe歐洲的全部國家都要高呢? [只需列出 name 。] (有些國家的記錄中,GDP是NULL,沒有填入資料的。)
1. select name
2. from world
3. where gdp>=all(select gdp from world where
continent='Europe' and gdp>0) and continent <> 'Europe';
7.在每一個州中找出最大面積的國家,列出洲份 continent, 國家名字 name 及面積 area。 (有些國家的記錄中,AREA是NULL,沒有填入資料的。)
1. SELECT continent, name, area
2. FROM world x
3. WHERE area >= ALL(SELECT area
4. FROM world y
5. WHERE y.continent=x.continent AND area>0)
8.列出洲份名稱,和每個洲份中國家名字按子母順序是排首位的國家名。(即每洲只有列一國)
1. select continent,name
2. from world a
3. where name<=all(select name
4. from world y
5. where y.continent=a.continent)
6. order by continent ;
9.找出洲份,當中全部國家都有少於或等於 25000000 人口. 在這些洲份中,列出國家名字name,continent 洲份和population人口。
1. select name,continent,population
2. from world x
3. where 25000000>=all(select population
4. from world y
5. where y.continent=x.continent and population>0 );
10.有些國家的人口是同洲份的所有其他國的3倍或以上。列出 國家名字name 和 洲份 continent。
1. select name,continent
2. from world x
3. where population/3>=all(select population
4. from world y
5. where y.continent=x.continent and y.name<>x.name );