【SQL練習】【SQLZOO】 5 SUM and COUNT
1.世界人口のトータル
【解答】
SELECT SUM(population) AS 'total population' FROM world;
2.大陸のリスト
【解答】
SELECT DISTINCT continent FROM world;
4.大きな国の数
【解答】
SELECT COUNT(name) AS count FROM world WHERE area >= 1000000;
5.バルト三国の人口
【解答】
SELECT SUM(population) AS 'total population' FROM world WHERE name IN ('Estonia', 'Latvia', 'Lithuania');
6.各大陸の国の数を数える
【解答】
SELECT continent, COUNT(name) AS count FROM world GROUP BY continent;
7.各大陸の大きな国を数える
【解答】
SELECT continent, COUNT(name) AS count FROM world WHERE population >= 10000000 GROUP BY continent;
8.大きな大陸を数える
【解答】
SELECT continent FROM world GROUP BY continent HAVING SUM(population) >= 100000000;