SQL Review: Simple SELECT Queries

You've done a good job getting to this point! Now that you've gotten a taste of how to write a basic query, you need to practice writing queries that solve actual problems.

SELECT query
SELECT column, another_column, … FROM mytable WHERE condition(s) ORDER BY column ASC/DESC LIMIT num_limit OFFSET num_offset;

Exercise

In the exercise below, you will be working with a different table. This table instead contains information about a few of the most populous cities of North America[1] including their population and geo-spatial location in the world.

Did you know?

Positive latitudes correspond to the northern hemisphere, and positive longitudes correspond to the eastern hemisphere. Since North America is north of the equator and west of the prime meridian, all of the cities in the list have positive latitudes and negative longitudes.

Try and write some queries to find the information requested in the tasks you know. You may have to use a different combination of clauses in your query for each task. Once you're done, continue onto the next lesson to learn about queries that span multiple tables.

Sorry but the SQLBolt exercises require a more recent browser to run.
Please upgrade to the latest version of Internet Explorer, Chrome, or Firefox!

Otherwise, continue to the next lesson: SQL Lesson 6: Multi-table queries with JOINs
Table: north_american_cities
Loading SQL...
Review 1 — Tasks
  1. List all the Canadian cities and their populations
  2. Order all the cities in the United States by their latitude from north to south
  3. List all the cities west of Chicago, ordered from west to east
  4. List the two largest cities in Mexico (by population)
  5. List the third and fourth largest cities (by population) in the United States and their population
Stuck? Read this task's Solution.
Solve all tasks to continue to the next lesson.
Finish above Tasks