Exercise 4.04 – aggregating data
In this exercise, you will utilize the world
database once again. You need some data about continents and regions for another news article, including the following information for each continent:
- The surface area for all the countries in that continent combined
- The average GNP per continent
- The total surface area per region for Asia
You will first connect to the world
database, get the per continent data, and then get the per region data. Perform the following steps to complete this exercise:
- Connect to the MySQL shell with Workbench and the appropriate user.
- Make sure that you are using the
world
database:USE world;
This outputs the following results:
- Obtain the data about each continent by writing the following query:
SELECT Continent, AVG(GNP), SUM(SurfaceArea) FROM country GROUP BY Continent;
This outputs the following results...