Recap - Boxes
Coddy SQL 여정의 기초 섹션에 포함된 레슨 — 72개 중 64번째.
챌린지
쉬움사용 가능한 테이블 및 열:
<strong>boxes</strong>:<strong>box_id</strong>,<strong>size</strong>
각 상자가 box_id로 정렬된 순서에서 다음 상자 안에 들어갈 수 있는지 확인하려 합니다. 상자가 다음 상자 안에 들어갈 수 있는 경우는 다음 상자의 크기가 현재 상자의 크기보다 큰 경우입니다. 각 상자를 순서에서 다음 상자와 비교하는 쿼리를 작성하세요. 상자가 다음 상자 안에 들어갈 수 있는 경우는 다음 상자의 크기가 현재 상자의 크기보다 엄격하게 큰 경우에 한합니다. 다음 단계를 따르세요:
-
can_fit_next라는 이름의 열을 생성하여 다음을 표시하세요:- 상자가 다음 상자 안에 들어갈 수 있는 경우 1 (true)
- 들어갈 수 없는 경우 0 (false)
- 마지막 상자는 비교할 다음 상자가 없으므로 자동으로 NULL을 받습니다
- 다음 상자 안에 들어갈 수 있는 상자만 표시하도록 필터링하세요 (where can_fit_next = 1)
box_id를 반환하세요- 결과를 box_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() 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