KEEP GOING

[MySQL] HackerRank : Placements Solution 본문

code review/sql

[MySQL] HackerRank : Placements Solution

jmHan 2021. 12. 21. 18:21
반응형

 

 

 

https://www.hackerrank.com/challenges/placements/problem

 

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

 

 

1. 정답 코드 

SELECT S.Name
 FROM Friends F
 INNER JOIN Students S ON S.ID = F.ID 
 INNER JOIN Packages P ON F.ID = P.ID
 INNER JOIN Packages PP ON F.Friend_ID = PP.ID
 WHERE P.Salary < PP.Salary
 ORDER BY PP.Salary

 

 

반응형
Comments