Let's learn a few things about this crazy world!
- Start by downloading and copying the contents of the
worlds
sample database file here - Open up your terminal, then type in
psql
at the prompt to start the Postgres REPL - Run the command
create database world;
- Switch to the new database by typing in
\c world
- Paste the contents of the SQL file you copied from step 1
Here's a model of what you now have loaded in the world
database. The first row is the table name, the second is the primary key and finally the remaining are any additional attributes.
- Using
count
, get the number of cities in the USA - Find out what the population and average life expectancy for people in Argentina (ARG) is
- Using
IS NOT NULL, ORDER BY, LIMIT
, what country has the highest life expectancy? - Using
LEFT JOIN, ON
, what is the capital of Spain (ESP)? - Using
LEFT JOIN, ON
, list all the languages spoken in the 'Southeast Asia' region
- Select 25 cities around the world that start with the letter 'F' in a single SQL query.