728x90
[해커랭크] Placements
https://www.hackerrank.com/challenges/placements/problem?isFullScreen=true
Placements | HackerRank
Write a query to output the names of those students whose best friends got offered a higher salary than them.
www.hackerrank.com
이번엔 from절에 테이블명을 잘못쓰고 왜 틀리지 이러고 있었다.. ㅋㅋ
p1, p2로 나눠서 접근하는 걸 처음 해봄!
select s.name
from students s
inner join friends f on s.id = f.id
inner join packages p1 on s.id = p1.id
inner join packages p2 on f.Friend_ID = p2.id
where p2.salary > p1.salary
order by p2.salary
728x90
'SQL' 카테고리의 다른 글
[프로그래머스] 조건에 부합하는 중고거래 댓글 조회하기 (0) | 2023.07.26 |
---|---|
[해커랭크] Contest Leaderboard (0) | 2023.07.26 |
[해커랭크] The Report (0) | 2023.07.24 |
[해커랭크] Binary Tree Nodes (0) | 2023.07.23 |
[해커랭크] Weather Observation Station 20 (0) | 2023.07.21 |