Report 1: Most decorated summer athletes
Now that you have a good understanding of the data, let's get back to our case study and build out the first element for the dashboard, Most Decorated Summer Athletes:
Your job is to create the base report for this element. Base report details:
- Column 1 should be
athlete_name
. - Column 2 should be
gold_medals
. - The report should only include athletes with at least 3 medals.
- The report should be ordered by gold medals won, with the most medals at the top.
This exercise is part of the course
Reporting in SQL
Exercise instructions
- Select
athlete_name
andgold_medals
by joiningsummer_games
andathletes
. - Only include
athlete_name
with at least 3 gold medals. - Sort the table so that the most
gold_medals
appears at the top.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Pull athlete_name and gold_medals for summer games
SELECT
____ AS athlete_name,
____ AS gold_medals
FROM ____ AS s
JOIN ____ AS a
ON ____
GROUP BY ____
-- Filter for only athletes with 3 gold medals or more
____
-- Sort to show the most gold medals at the top
ORDER BY ____;