Recap - Pictures
CoddyのSQLジャーニー「基礎」セクションの一部 — レッスン 63/72。
チャレンジ
簡単利用可能なテーブルと列:
picture_characteristics:day_of_month,ink_liters,colors_numpicture_interests:day_of_month,num_people_interested
絵画には、インクの量(リットル単位)、色の数、それらを購入したい人の数など、さまざまな特性があります。
アーティストがリソース(インクと色)を少なく使いながら、人々からのポジティブな関心を維持している日を特定したいと思います。コストを節約するために、アーティストはインクと色を少なく使うべきです。このチャレンジでは、この仮説を検証します。以下のステップに従ってください:
- 以下の項目の日次差分を計算:
- ink_liters(この列を
ink_diffと命名) - colors_num(この列を
colors_diffと命名)
- ink_liters(この列を
- 結果をフィルタリングして、以下の条件を満たす日だけを表示:
- ink_diff が負(インク使用量の減少を示す)
- colors_diff が負(使用色数の減少を示す)
- num_people_interested がゼロより大きい(少なくとも1人が絵に興味を持っている — データにはゼロ興味の日が含まれる可能性があることに注意)
- ランキング列(
day_rank)を作成:num_people_interestedに基づいて、日を1からNまでランク付け- 興味を持つ人の数が多いほど低いランク(1が最高)
- 返す:
day_of_monthday_rank
結果を day_rank の昇順で並べ替える
自分で試してみよう
基礎のすべてのレッスン
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() Function8Statistics
Built-In Aggregate Part 1Built-In Aggregate Part 2Grouping Part 1Grouping Part 2Subqueries Part 1Subqueries Part 2Recap - Total Gain ShopRecap - Scooter ShopRecap - Coffee Shop11Window Functions part 1
ROW_NUMBER functionORDER BY criterionPARTITION BY criterionPARTITION & ORDERLEAD & LAG FunctionsRecap - LEAD & LAGRecap - PicturesRecap - Boxes3Specific 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