Skip to content

Joining Data with SQL

Here you can access every table used in the course. To access each table, you will need to specify the world schema in your queries (e.g., world.countries for the countries table, and world.languages for the languages table).


Note: When using sample integrations such as those that contain course data, you have read-only access. You can run queries, but cannot make any changes such as adding, deleting, or modifying the data (e.g., creating tables, views, etc.).

Take Notes

Add notes about the concepts you've learned and SQL cells with queries you want to keep.

Add your notes here

Spinner
DataFrameas
world_info
variable
-- Add your own queries here
SELECT * 
FROM world.countries;
Spinner
DataFrameas
df
variable
SELECT *
FROM world.languages;
  • JOIN the table
  • Select code, language, country, continent
Spinner
DataFrameas
df1
variable
SELECT c.code,
		l.name AS language,
		c.name AS country,
		c.continent
FROM world.countries AS c
INNER JOIN world.languages AS l
		ON c.code = l.code
ORDER BY c.name;
		

List Countries and Their Currencies

  • Write a query that shows all countries with their respective currency names.
Spinner
DataFrameas
df3
variable
SELECT *
FROM world.currencies;
Spinner
DataFrameas
df2
variable
SELECT co.code, co.name AS country, cu.basic_unit AS currency
FROM world.countries AS co
INNER JOIN world.currencies AS cu
	ON co.code = cu.code;
  • Write a query to show the GDP and population for each country in the database. The result should include the country name, and GDP.
Spinner
DataFrameas
df4
variable
SELECT *
FROM world.economies;
Spinner
DataFrameas
df5
variable
SELECT c.code, c.name AS country, e.year, e.gdp_percapita
FROM world.countries AS c
INNER JOIN world.economies AS e
	ON c.code = e.code;
  • Write a query to find all countries that speak more than one language. Show the country name and the number of languages spoken.
Spinner
DataFrameas
df6
variable
SELECT c.code,
		COUNT(l.name) AS number_of_language,
		c.name AS country
FROM world.countries AS c
INNER JOIN world.languages AS l
		ON c.code = l.code
GROUP BY c.code, c.name;