Skip to content

Instantly share code, notes, and snippets.

@AlistairBrownlee
Created August 27, 2020 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlistairBrownlee/37c0df35bf5d33c6f0322e7daf737d8d to your computer and use it in GitHub Desktop.
Save AlistairBrownlee/37c0df35bf5d33c6f0322e7daf737d8d to your computer and use it in GitHub Desktop.
SELECT COUNT(*)
FROM countries
WHERE continent = 'Africa';
SELECT COUNT(*)
FROM countries
WHERE continent = 'Africa';
SELECT id, continent
FROM countries
GROUP BY continent;
SELECT *
FROM population_years
LIMIT 10;
SELECT SUM(population) AS 'Population of Oceana in 2005 (in millions)'
FROM population_years
WHERE year = 2005 AND country_id = 213;
SELECT countries.name, MIN(population_years.population)
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE year = 2007;
SELECT AVG(population_years.population) AS 'Poland Average Population'
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE countries.name = 'Poland';
SELECT COUNT(*) AS 'Countries containing The'
FROM countries
WHERE name LIKE '%The%';
SELECT countries.continent, SUM(population_years.population) AS 'Pupulation in 2010 (in millions)'
FROM countries
JOIN population_years
ON countries.id = population_years.country_id
WHERE year = 2010
GROUP BY countries.continent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment