문제
Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be ordered by the salary amount offered to the best friends. It is guaranteed that no two students got same salary offer.
*
실행 코드
3개의 테이블이 제시되어 있는데, 먼저 본인을 기준으로 연봉 테이블을 구해준 뒤, 본인의 친구 기준으로 연봉 테이블을 연결해주어야 한다.
나는 from절에서 서브쿼리를 사용해서 조건을 추가했다.
1. 서브쿼리를 통해 본인의 연봉 제시
2. 본 쿼리에서 'INNER JOIN Packages P ON P.ID = A.Friend_ID' 구문을 추가하여 친구의 연봉 구분한 후 WHERE절로 비교
'Data > SQL' 카테고리의 다른 글
[프로그래머스] 서울에 위치한 식당 목록 출력하기 (0) | 2023.03.16 |
---|---|
[HackerRank] New Companies (0) | 2023.03.14 |
[HackerRank] Top Competitors (0) | 2023.03.11 |
[프로그래머스] 식품분류별 가장 비싼 식품의 정보 조회하기 (0) | 2023.03.09 |
[프로그래머스] 즐겨찾기가 가장 많은 식당 정보 출력하기 (0) | 2023.03.05 |