𝙎𝙌𝙇

[HackerRank] Placements

콜라맛갈비 2023. 7. 27. 14:10
728x90

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

 

베스트 프렌드가 자신보다 더 높은 salary를 받는 학생들의 이름을 출력.

베스트 프렌드가 받는 salary를 오름차순으로 정렬.

(동일한 값의 salary는 없음)

 

select s.name
from students s 
	left join friends f on s.id = f.id 
    left join packages p on s.id = p.id
    left join packages pp on f.friend_id = pp.id
where p.salary < pp.salary
order by pp.salary

 

 

 

 

728x90