1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > sqlzoo刷题笔记-02 | SUM and COUNT

sqlzoo刷题笔记-02 | SUM and COUNT

时间:2019-09-09 12:07:59

相关推荐

sqlzoo刷题笔记-02 | SUM and COUNT

网址:/wiki/SUM_and_COUNT

1、Show the totalpopulationof the world.

显示世界总人口数。

SELECT SUM(population)FROM world

2、List all the continents - just once each.

列出所有大陆 - 每个大陆只列出一次。

SELECT DISTINCT continentFROM world

3、Give the total GDP of Africa

给出非洲的国内生产总值。

SELECT SUM(gdp)FROM worldWHERE continent = 'Africa'

4、How many countries have anareaof at least 1000000

有多少国家面积至少为 1000000。

SELECT COUNT(name)FROM worldWHERE area >= 1000000

5、What is the totalpopulationof ('Estonia', 'Latvia', 'Lithuania')

'Estonia', 'Latvia', 'Lithuania'的总人口数。

SELECT SUM(population)FROM worldWHERE name in ('Estonia', 'Latvia', 'Lithuania')

6、For eachcontinentshow thecontinentand number of countries.

显示每个大陆和大陆包含的国家数量。

SELECT continent,COUNT(name)FROM worldGROUP BY continent

7、For eachcontinentshow thecontinentand number of countries with populations of at least 10 million.

显示每个大陆和大陆包含的国家(人口数量不少于1000万)数量。

SELECT continent,COUNT(name)FROM worldWHERE population >= 10000000GROUP BY continent

8、List the continents thathavea total population of at least 100 million.

列出总人口不少于100000000的大洲。

SELECT continentFROM worldGROUP BY continentHAVING SUM(population) >= 100000000

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。