Workspace
Feras Tajuddin/

Joining Data in SQL

0
Beta
Spinner

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

Unknown integration
DataFrameavailable as
world_info
variable
-- Add your own queries here
SELECT *
FROM world.languages 
LIMIT 5
This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.

Explore Datasets

Use the tables to explore the data and practice your skills!

  • Combine the states and countries tables into one table.
    • The final result should have a name column, a continent column, and an indep_year column. Use the local_name column from the countries table as the name.
    • The final result should not include duplicate rows.
  • Return the country_code, fertility_rate, and life_expectancy from the populations table.
    • Only return countries which are categorized as 'large' in the countries_plus table.
    • Filter for data from 2015.
  • Return the local_name aliased as country_name, continent, surface_area, the number of official languages, gdp_percapita, and unemployment_rate from the countries, economies, and languages tables.
    • Ensure that all records from the countries table are preserved, regardless whether a match is present in the economies or languages tables.
    • Only include economy data from 2015.
    • Sort your results by gdp_percapita in descending order.
Unknown integration
DataFrameavailable as
df
variable
SELECT name, continent, indep_year, fert_rate
FROM world.states
UNION
SELECT local_name AS name, continent, indep_year, NULL AS fert_rate
FROM world.countries;
This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.
Unknown integration
DataFrameavailable as
df1
variable
SELECT p.country_code, p.fertility_rate, p.life_expectancy
FROM world.populations AS p
INNER JOIN world.countries_plus AS cp
ON p.country_code= cp.code
WHERE geosize_group = 'large'
 AND year = 2015;
This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.
Unknown integration
DataFrameavailable as
df2
variable
SELECT c.local_name AS country_name, c.continent, c.surface_area, e.gdp_percapita, e.unemployment_rate
FROM world.economies AS e
LEFT JOIN world.countries AS c
ON e.code = c.code
LEFT JOIN world.languages AS l -- Added alias for table
ON c.code = l.code
WHERE year = 2015
ORDER BY gdp_percapita DESC;
This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.
  • AI Chat
  • Code