Recap - Self Join
Coddy SQL 여정의 기초 섹션에 포함된 레슨 — 72개 중 47번째.
챌린지
어려움사용 가능한 테이블 및 컬럼:
<strong>friends</strong>:<strong>id</strong>,<strong>name</strong>,<strong>friend_id</strong>
friends 테이블의 각 사람에 대해, 그들이 가진 모든 친구의-친구 연결을 찾으세요. 친구의-친구 연결은 사람 A가 사람 B와 친구이고, B가 차례로 사람 C와 친구일 때 발생합니다. 이러한 연결을 세 개의 컬럼으로 나열하세요:
- friend1: 시작 사람
- friend2: 직접적인 친구
- friend3: 친구의 친구
규칙:
- friend3가 friend1과 같은 사람인 경우는 포함하지 마세요
- 결과를 friend1의 이름으로 내림차순 정렬하세요
예시: Alice가 Bob과 친구이고, Bob이 Carol과 친구라면, Alice-Bob-Carol은 유효한 친구의-친구 연결입니다.
직접 해보기
기초의 모든 레슨
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