SQL

[해커랭크] Placements

주스 JUICE 2023. 7. 24. 21:36
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