Posts

Showing posts from March, 2023

SQLZOO ANSWERS - SUM and COUNT

1.  Show the total population of the world. SELECT SUM(population)      FROM world 2.  List all the continents - just once each. SELECT DISTINCT continent       FROM world 3.  Give the total GDP of Africa SELECT SUM(gdp)              FROM world                      WHERE continent= 'Africa' 4. How many countries have an area of at least 1000000 SELECT COUNT(name)            FROM world where area>=1000000 5.  What is the total population of ('Estonia', 'Latvia', 'Lithuania') SELECT SUM(population)            FROM world                      WHERE name in ('Estonia', 'Latvia', 'Lithuania') 6.  For each continent show the continent and number of countries. SELECT continent,COUNT(name)  ...

SQLZOO ANSWERS - SELECT within SELECT Tutorial

1.   List each country  name  where the  population  is larger than that of 'Russia'. SELECT name FROM world   WHERE population >      (SELECT population FROM world       WHERE name='Russia') 2.  Show the countries in Europe with a per-capita GDP greater than 'United Kingdom'. SELECT name FROM world       WHERE  gdp/population >            (SELECT sum(gdp/population) from world                 WHERE name = 'United Kingdom')            AND continent = 'Europe' 3. List the  name  and  continent  of countries in the continents containing either  Argentina  or  Australia .                            Order by name of the country. SELECT name,continent  FROM world W...