Recap - Boxes
CoddyのSQLジャーニー「基礎」セクションの一部 — レッスン 64/72。
チャレンジ
簡単利用可能なテーブルと列:
<strong>boxes</strong>:<strong>box_id</strong>,<strong>size</strong>
各ボックスがシーケンス内の次のボックスに収まるかどうかを確認します(シーケンスは box_id で並べ替えられます)。ボックスは、次のボックスのサイズが現在のボックスより大きい場合に、次のボックスに収まります。各ボックスをシーケンス内の次のボックスと比較するクエリを書いてください。ボックスは、次のボックスのサイズが現在のボックスのサイズよりも厳密に大きい場合に限り、次のボックスに収まります。以下のステップに従ってください:
- 列
can_fit_nextを作成し、以下を表示します:- ボックスが次のボックスに収まる場合 1 (true)
- 収まらない場合 0 (false)
- 最後のボックスは、比較する次のボックスがないため、自動的に NULL が付与されます
- 次のボックスに収まるボックスのみを表示するフィルタリングを行います(can_fit_next = 1 の場合)
box_idを返します- 結果を box_id の昇順で並べ替えます
自分で試してみよう
基礎のすべてのレッスン
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() Function8Statistics
Built-In Aggregate Part 1Built-In Aggregate Part 2Grouping Part 1Grouping Part 2Subqueries Part 1Subqueries Part 2Recap - Total Gain ShopRecap - Scooter ShopRecap - Coffee Shop11Window Functions part 1
ROW_NUMBER functionORDER BY criterionPARTITION BY criterionPARTITION & ORDERLEAD & LAG FunctionsRecap - LEAD & LAGRecap - PicturesRecap - Boxes3Specific 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