Skip to content

Instantly share code, notes, and snippets.

@wolframalexa
Created March 26, 2020 20:56
Show Gist options
  • Save wolframalexa/6bef9bf968486ca3ab0f156532affae2 to your computer and use it in GitHub Desktop.
Save wolframalexa/6bef9bf968486ca3ab0f156532affae2 to your computer and use it in GitHub Desktop.
SQL Countries of the World Project on Codecademy
SELECT COUNT(id) FROM countries WHERE continent = 'Africa';
SELECT SUM(population) FROM population_years JOIN countries ON population_years.country_id = countries.id WHERE countries.continent = 'Oceania' AND year = 2005;
SELECT AVG(population) FROM population_years JOIN countries ON population_years.country_id = countries.id WHERE countries.continent = 'South America' AND year = 2003;
SELECT countries.name FROM population_years JOIN countries ON population_years.country_id = countries.id WHERE population_years.year = 2007 ORDER BY population ASC LIMIT 1;
SELECT AVG(population) FROM population_years JOIN countries ON population_years.country_id = countries.id WHERE countries.name = 'Poland';
SELECT * FROM countries WHERE name LIKE '%The%';
SELECT countries.continent, SUM(population) FROM population_years JOIN countries ON population_years.country_id = countries.id GROUP BY countries.continent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment