Recap - Join
CoddyのSQLジャーニー「基礎」セクションの一部。レッスン 45/72。
チャレンジ
中級利用可能なテーブルとカラム:
<strong>orders</strong>:<strong>id</strong>,<strong>customer_id</strong><strong>products</strong>:<strong>id</strong>,<strong>unit_price</strong>,<strong>units_in_stock</strong><strong>order_items</strong>:<strong>id</strong>,<strong>order_id</strong>,<strong>product_id</strong>,<strong>quantity</strong>
unit_priceが10未満の商品を注文した顧客の顧客IDを取得し、各顧客が注文したそれらの安価な商品のquantityの合計を一覧表示してください。
以下のカラムを返してください:
- customer_id
- total_quantity (各顧客における
unit_price< 10の商品の数量の合計)
自分で試してみよう
-- タスクが求めるグループ化列と集計値をリストする
SELECT ____
FROM orders
-- 各結合には、id列をそれを指す列に一致させる条件が必要です
INNER JOIN order_items ON ____
INNER JOIN products ON ____
-- 次に、タスクが説明するしきい値を満たす行のみを残す
WHERE ____
GROUP BY orders.customer_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自分で練習してみよう: SQLプレイグラウンド