報表 4:各區域的最高運動員與 GDP 百分比
儀表板上的最後一個報表是 Report 4: Avg Tallest Athlete and % of world GDP by Region。
報表細節:
- 第 1 欄應為
region,來源是countries資料表。 - 第 2 欄為
avg_tallest,代表在每個區域內,各國「最高運動員」的height先各自取最高後再取平均。 - 第 3 欄為
perc_world_gdp,代表該區域佔全世界 GDP 的百分比。 - 只包含
winter_games(不含夏季賽事)。
本練習屬於課程
SQL 報表製作
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
SELECT
-- Pull in country_id and height
____,
____,
-- Number the height of each country's athletes
____ AS row_num
FROM ____ AS w
JOIN ____ AS a
ON ____
GROUP BY ____, ____
-- Order by country_id and then height in descending order
ORDER BY ____, ____ DESC;