Basic Join Part 2
CoddyのSQLジャーニー「基礎」セクションの一部 — レッスン 44/72。
結合(Join)は、作成したテーブルに対しても使用できます。ネストされたテーブルを結合で組み合わせるには、AS を追加してネストされたクエリに名前を付けて識別する必要があります。
例えば:
SELECT table1.col1, table2.col2, ...
FROM table1, (SELECT * FROM table) AS table2
WHERE table1.id = table2.idチャレンジ
簡単利用可能なテーブルとカラム:
<strong>grades</strong>:<strong>course_id</strong>,<strong>student_id</strong>,<strong>grade</strong><strong>students</strong>:<strong>id</strong>,<strong>name</strong>
各学生の平均成績を計算し、それぞれの名前と平均成績を返してください。
カラム名を student、grade としてください。
平均を小数点以下第2位に丸め、結果を平均成績の昇順でソートしてください。
チートシート
ネストされたクエリを使用してテーブルを結合するには、AS を使用してネストされたクエリに名前を付けます:
SELECT table1.col1, table2.col2, ...
FROM table1, (SELECT * FROM table) AS table2
WHERE table1.id = table2.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() 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