開始使用免費開始

每位客戶的平均評分

和你剛才做的類似,這次要查看「以客戶為單位」的平均電影評分。 你將取得一個資料表,包含每位客戶給出的平均評分。此外,還要包含每位客戶的評分次數與租借電影次數。只回報電影租借次數超過 7 次的客戶,並依平均評分由小到大排序。

本練習屬於課程

以資料驅動的 SQL 決策制定

檢視課程

練習說明

  • renting 資料表中以 customer_id 分組,回報 customer_id、平均評分、評分次數,以及電影租借次數。
  • 僅選出電影租借次數超過 7 次的客戶。
  • 將結果資料表依平均評分由小到大排序。

動手互動練習

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

SELECT ___, -- Report the customer_id
      ___,  -- Report the average rating per customer
      ___,  -- Report the number of ratings per customer
      ___  -- Report the number of movie rentals per customer
FROM renting
GROUP BY customer_id
___ -- Select only customers with more than 7 movie rentals
ORDER BY ___; -- Order by the average rating in ascending order
編輯並執行程式碼