Recap - Total Gain Shop
CoddyのSQLジャーニー「基礎」セクションの一部 — レッスン 40/72。
チャレンジ
簡単利用可能なテーブルと列:
<strong>shop</strong>:<strong>price</strong>,<strong>quantity</strong>,<strong>category</strong>,<strong>list_date</strong>
あなたのタスクは、January 1, 2015からMarch 18, 2015までの期間におけるショップの各アイテムカテゴリの総収益を計算することです。データ入力システムの体系的なエラーのため、データベース内のすべての価格値は固定額だけ本来の値より低くなっています。
これらの価格を修正するには:
- まず、指定された日付範囲(
2015-01-01(2015年1月1日)から2015-03-182015年3月18日)内のすべてのアイテムの平均価格を計算します - この平均価格を各アイテムの元の価格に加えて、正しい価格値を得ます
- 各カテゴリについて、修正された価格を数量で乗じてこれらの値を合計することで、総収益を計算します
- 結果を(
category、total_revenue)ペアとして提示し、総収益の降順でソートします
自分で試してみよう
基礎のすべてのレッスン
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