解讀錯誤訊息
在執行 SQL 查詢時,你難免會遇到錯誤。理解如何解讀錯誤訊息,才能正確判斷錯誤的類型。
主控台中有兩個彼此獨立的查詢,各自執行時都會產生錯誤。在這個練習中,你會分別執行每個查詢、閱讀錯誤訊息,並釐清與修正錯誤。
本練習屬於課程
SQL 報表製作
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
-- Run the query, then convert a data type to fix the error
SELECT AVG(pop_in_millions) AS avg_population
FROM country_stats;
/*SELECT
s.country_id,
COUNT(DISTINCT s.athlete_id) AS summer_athletes,
COUNT(DISTINCT w.athlete_id) AS winter_athletes
FROM summer_games AS s
JOIN winter_games_str AS w
ON s.country_id = w.country_id
GROUP BY s.country_id;*/