Recap - Creatures
CoddyのSQLジャーニー「基礎」セクションの一部 — レッスン 70/72。
チャレンジ
中級利用可能なテーブルとカラム:
<strong>creatures</strong>:<strong>creature_name</strong>,<strong>preference</strong>,<strong>has_legs</strong>
このチャレンジでは、大切なパートナーを見つけたいクリーチャーたちがいます。彼らがマッチする相手を見つけるのを手伝う必要があります。
各クリーチャーは preference 値を持ち、足があるか(has_legs)ないかのどちらかです。
ルール:
- クリーチャーは、同じ
has_legsの値を持つ相手とのみマッチングされます - 各グループ(
has_legsが true/false)内で、クリーチャーをpreference順に並べます NTILE(total_creature_count/2)を使用してcouple_matcher番号を割り当てます- 両方のグループは 1 から番号が振られます(小さいグループは単に埋まるバケットの数が少なくなります)
例: 合計 10 体のクリーチャー(足ありが 6 体、足なしが 4 体)の場合
- 足のあるクリーチャー:
preferenceでランク付けされ、couple_matcher1-5 が割り当てられます - 足のないクリーチャー:
preferenceでランク付けされ、couple_matcher1-5 が割り当てられます - 結果: 複数の異なるカップルが同じ
couple_matcher番号を持つことができます
自分で試してみよう
基礎のすべてのレッスン
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