목록셀프조인 (2)
오랑우탄의 반란
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/c4tliu/btsJ0NIcKhg/kFUD9GuOuEf5haUOJtoWm0/img.png)
오늘도 오랑이는 문제를 풉니다. Symmetric PairsYou are given a table, Functions, containing two columns: X and Y.Two pairs (X1, Y1) and (X2, Y2) are said to be symmetric pairs if X1 = Y2 and X2 = Y1.Write a query to output all such symmetric pairs in ascending order by the value of X. List the rows such that X1 ≤ Y1. Sample InputSample Output20 2020 2122 23 풀이과정x1 = y2 & x2 = y1 인 행이 2개 이상인 경우x 첫번째 풀이는 셀프조인..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/veVkJ/btsIn6jOl1d/fMdMbYt7mT6SswFhE7Tc6K/img.png)
테이블을 자기 자신과 조인하는 셀프 조인에 대해 알아보겠습니다. SELF JOIN은 한 테이블 내에서 칼럼 간, 개별 값 간 대조가 필요할 때 사용할 수 있습니다. 문법은 JOIN/쉼표로 연결하고 (필수) 별칭을 붙여줍니다.SELECT column_name(s)FROM table1 T1, table1 T2WHERE condition; 아래 두 가지 예시로 SELF JOIN의 활용을 살펴보겠습니다. LeetCode | 197. Rising Temperaturehttps://leetcode.com/problems/rising-temperature/ 하나의 테이블 내의 날짜 값과 온도 값에 대한 비교가 필요하기 때문에 self join 을 사용해서 이어줍니다. from weather w1 join we..