LoslegenKostenlos loslegen

Filtering with a JOIN

When adding a filter to a query that requires you to reference a separate table, there are different approaches you can take. One option is to JOIN to the new table and then add a basic WHERE statement.

Your goal is to create a report with the following characteristics:

  • First column is bronze_medals, or the total number of bronze.
  • Second column is silver_medals, or the total number of silver.
  • Third column is gold_medals, or the total number of gold.
  • Only summer_games are included.
  • Report is filtered to only include athletes age 16 or under.

In this exercise, use the JOIN approach.

Diese Übung ist Teil des Kurses

Reporting in SQL

Kurs anzeigen

Anleitung zur Übung

  • Create a query that pulls total bronze_medals, silver_medals, and gold_medals from summer_games.
  • Use a JOIN and a WHERE statement to filter for athletes ages 16 and below.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

-- Pull summer bronze_medals, silver_medals, and gold_medals
SELECT 
	____, 
    ____, 
    ____
FROM ____ AS s
JOIN ____ AS a
ON ____
-- Filter for athletes age 16 or below
WHERE ____;
Code bearbeiten und ausführen