Recap - Creatures
Coddy SQL 여정의 기초 섹션에 포함된 레슨 — 72개 중 70번째.
챌린지
중급사용 가능한 테이블 및 컬럼:
<strong>creatures</strong>:<strong>creature_name</strong>,<strong>preference</strong>,<strong>has_legs</strong>
이 챌린지에서 우리는 소중한 반쪽을 찾고 싶어 하는 생명체들을 돕고자 합니다. 그들이 짝을 찾을 수 있도록 도와주어야 합니다.
각 생명체는 preference(선호도) 값을 가지고 있으며, has_legs(다리 유무)에 따라 다리가 있거나 없습니다.
규칙:
- 생명체는 동일한
has_legs값을 공유하는 다른 생명체와만 매칭됩니다. - 각 그룹(
has_legstrue/false) 내에서preference순으로 생명체를 정렬합니다. NTILE(total_creature_count/2)를 사용하여couple_matcher번호를 할당합니다.- 두 그룹 모두 1부터 번호가 매겨집니다 (더 작은 그룹은 단순히 더 적은 버킷을 채우게 됩니다).
예시: 총 10마리의 생명체 (다리가 있는 생명체 6마리, 없는 생명체 4마리)
- 다리가 있는 생명체: 선호도에 따라 순위가 매겨지고,
couple_matcher1-5가 할당됩니다. - 다리가 없는 생명체: 선호도에 따라 순위가 매겨지고,
couple_matcher1-5가 할당됩니다. - 결과: 여러 개의 서로 다른 커플이 동일한
couple_matcher번호를 가질 수 있습니다.
직접 해보기
기초의 모든 레슨
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