主要涉及到的知识点是聚合函数:sum and count等
This tutorial is about aggregate functions such as COUNT, SUM and AVG. An aggregate function takes many values and delivers just one value. For example the function SUM would aggregate the values 2, 4 and 5 to deliver the single value 11

select sum(population) from world;列出每个不同的洲,使用distinct去重
select distinct(continent) from world;计算非洲的总gdp,sum求和
select sum(gdp) from world where continent='Africa';统计count多少个国家的面积大于1000000
select count(name) from world
where area > 1000000;3个国家的总人口sum
select sum(population) from world
where name in ('Estonia', 'Latvia', 'Lithuania');每个地区continent有多少个国家count
select continent, count(name) -- 统计总数
from world
group by continent; -- 地区分组加上where条件再进行分组
select continent, count(name)
from world
where population >= 10000000 -- 先用where进行筛选
group by continent;having是对分组之后的结果进行筛选
select continent
from world
group by continent -- 先分组再进行筛选
having sum(population) >= 100000000;统计每个洲中国家的数量
select continent, count(name)
from world
group by continent; -- 分组统计每个洲的人口总数
select continent, sum(population) -- 人口求和
from world
group by continent;where语句在group by之前
select continent,count(name)
from world
where population > 20000000
group by continent;The HAVING clause is tested after the GROUP BY
select continent, sum(population) -- 统计总人口
from world
group by continent
having sum(population) > 500000000; -- 总人口满足的条件