顧客ごとの平均評価
先ほどと同様に、今度は顧客に対する映画の平均評価を見ていきます。 各顧客が付けた平均評価の表を作成し、さらに評価の件数と、顧客ごとの映画レンタル数も含めます。映画を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