A Gentle Introduction to

SQL


Pick an engine:

CIA World Factbook: aggregate functions

This tutorial concerns aggregate functions such as COUNT, SUM and AVG.

Exercises

Using SUM, COUNT, MAX, AVG, DISTINCT and ORDER BY.

1a Show the total population of the world.

1b List all the regions - just once each.

1c List the countries which have a GDP greater than the whole of Africa

Using GROUP BY and HAVING.

2a For each region show the region and number of countries.

2b For each region show the region and number of countries with populations of at least 10 million.

2c List the regions with total populations of at least 100 million.


The next tutorial is looks at the Movie database. It shows how queries may use records from two or more tables.