Recap - Books
CoddyのSQLジャーニー「基礎」セクションの一部 — レッスン 71/72。
チャレンジ
簡単利用可能なテーブルと列:
<strong>books</strong>:<strong>book</strong>,<strong>page</strong>,<strong>words</strong>
本には多くのページがあり、各ページには多くの単語があります。
このチャレンジでは、各ページまでのこれらの本に関する累積メトリクスを計算します。以下のステップに従ってください:
- まず、各本の各ページまでの以下の累積集計を計算します:
- Total words (
total_words) - Maximum words (
max_words) - Minimum words (
min_words) - Average words (
avg_words)
- Total words (
- 次に、本内の各ページに対して、比率
(avg_words - min_words)/(total_words - min_words)を計算します。 - 最後に、各本に対して:
- この比率に基づいてページを昇順で密にランク付けします(この列を
ratio_rankとします) - 結果を最初に book によって、次に
ratio_rankによって並べ替えます。
- この比率に基づいてページを昇順で密にランク付けします(この列を
注意:すべての集計 (total, max, min, avg) は累積的であるべきです。つまり、各本の現在のページを含むそれまでのすべてのページを考慮します。
自分で試してみよう
基礎のすべてのレッスン
4More Keywords
The IN keywordThe BETWEEN keywordThe LIKE keywordThe AS keywordRecap - Cellphone Models2Conditions
Conditions BasicsThe AND keywordThe OR keywordThe NOT keywordMultiple Conditions CombinedParenthesisBooleans5Arithmetic Operations
Mathematical OperatorsMathematical ColumnsThe Modulo OperationThe ROUND() Function3Specific Return Format
Null valuesSort Results Part 1Sort Results Part 2Recap - Cyber Security FirmLimit number of recordsRecap - Vehicle Factory6Intro Challenges
Recap - Parliamentary ElectionRecap - Police Criminal ArrestRecap - Bar Beverage ContainerRecap - Engineer new columns