SQL GROUP BY and SUM

List the continents with a combined population of at least 100 million.

World Table

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    10009000990
...
...

      

I started with

SELECT continent FROM world WHERE ...

and kind of stuck here.

Not sure how I can use GROUP BY and SUM. I need to GROUP BY continent

, and SUM(population)

some of them, but I'm still involved in how things connect.

expected output

continent
Africa
Asia
Eurasia
Europe
North America
South America

      

+3


source to share


1 answer


SELECT   continent, SUM(population)
FROM     world
GROUP BY continent
HAVING   SUM(population) >= 100000000

      



+4


source







All Articles