Skip to content

Instantly share code, notes, and snippets.

@Sudhir-KNair
Last active April 6, 2020 23:34
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 Sudhir-KNair/2de0aa4ff43c4b2084c115d03ace0a58 to your computer and use it in GitHub Desktop.
Save Sudhir-KNair/2de0aa4ff43c4b2084c115d03ace0a58 to your computer and use it in GitHub Desktop.
Codeacademy world population
select count(*) FROM countries
where continent like '%africa%';
select continent,round(sum(population),2) as 'Total Population' from population_years
join
countries
on countries.id = population_years.country_id
where continent like '%Oceania%' AND year = 2005
group by continent;
select continent,round(AVG(population),2) as 'Average Population' from population_years
join
countries
on countries.id = population_years.country_id
where continent like '%South America%' AND year = 2003
group by continent;
Select name,min(population) from population_years
join
countries
on countries.id = population_years.country_id
where year = 2007;
select name,round(AVG(population),2) as 'Average Population' from population_years
join
countries
on countries.id = population_years.country_id
where name like '%Poland%'
group by name;
select count(*) FROM countries
where name like '%The%';
select continent,round(sum(population),2) as 'Total Population' from population_years
join
countries
on countries.id = population_years.country_id
where year = 2005
group by continent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment