Friday, September 7, 2007

BBC Country Profile: Aggregate functions

1a. Show the total population of the world.
Select sum(population) from bbc;

1b. List all the regions - just once each.
Select distinct(region) from bbc;

1c. Give the total GDP of Africa
Select sum(gdp) from bbc
where region = 'Africa';

1d. How many countries have an area of at least 1000000
select count(region) from bbc where area >= 1000000;

1e. What is the total population of ('France','Germany','Spain')
select sum(population) from bbc
where name in('France','Germany','Spain');

No comments: