Recap - Scooter Shop
CoddyのSQLジャーニー「基礎」セクションの一部。レッスン 41/72。
チャレンジ
簡単利用可能なテーブルとカラム:
<strong>scooters</strong>:<strong>model</strong>,<strong>brand</strong>,<strong>has_lights</strong>,<strong>price</strong>
スクーターショップのマネージャーとして、多くのスクーターがオリジナルではない(つまりモデル名がない)ことに気づきました。さらに、状態の良くないスクーターは通常ライトがついていません。
あなたのタスクは2つのステップで構成されます:
- まず、ショップ内のすべてのスクーターの価格に、全体の平均価格を加算します。
- 次に、良好でオリジナルのスクーター(つまり、モデル名があり、ライトがついているスクーター)のみを考慮して、
brandごとの平均価格を計算します。
結果には brand と平均価格 avg_price を含める必要があります。結果は平均価格の昇順で並べ替えてください。
自分で試してみよう
-- ステップ2: 再構築された行をフィルタリングし、グループごとに平均する
SELECT ____
FROM (
-- ステップ1: すべての行を再構築し、値を調整されたものに置き換える
SELECT model, brand, has_lights, ____ AS price
FROM scooters
)
WHERE ____ AND ____
GROUP BY ____
ORDER BY ____基礎のすべてのレッスン
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自分で練習してみよう: SQLプレイグラウンド