開始使用免費開始

HAVING 與排序

篩選與排序常常一起使用,藉由對結果排序,可以讓你更容易解讀。

現在就透過一個查詢來看看效果:找出哪些國家的平均電影預算最高。

本練習屬於課程

SQL 中級

檢視課程

練習說明

  • films 中選取 country,以及四捨五入到小數點後第 2 位的平均預算作為 average_budget
  • country 對結果分組。
  • 僅保留平均預算超過 10 億(1000000000)的國家。
  • average_budget 由大到小排序。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

-- Select the country and average_budget from films
___
-- Group by country
___
-- Filter to countries with an average_budget of more than one billion
___
-- Order by descending order of the aggregated budget
___
編輯並執行程式碼