본문 바로가기
카테고리 없음

sqlzoo.net 답 (SUM and COUNT)

https://sqlzoo.net/wiki/SUM_and_COUNT

 

SUM and COUNT - SQLZOO

World Country Profile: Aggregate functions 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 del

sqlzoo.net

SUM and COUNT

--no1

select sum(population)
from world

 

--no2

select distinct continent from world

 

--no3

select sum(gdp)
from world
where continent = 'Africa'

 

--no4

select count(name)
from world
where area >= 1000000

 

 

--no5

select sum(population)
from world
where name in ('france', 'germany', 'spain')


--no6

select continent, count(name)
from world
group by continent


--no7

select continent, count(name)
from world
where population >= 10000000
group by continent


--no8

select continent from world
group by continent having sum(population) >= 100000000
select distinct continent
from world x
where 100000000 <= 
(select sum(population) from world y where x.continent = y.continent)