🤔 문제 분석
1. There are 3 query.
2. Write a query to output the names of those students whose best friends got offered a higher salary than them.
3. Names must be ordered by the salary amount offered to the best friends. It is guaranteed that no two students got same salary offer.
💡 풀이
SELECT S.Name
FROM Students AS S
INNER JOIN (SELECT F.ID, F.Friend_ID, P.Salary
FROM Friends AS F
INNER JOIN Packages AS P ON F.Friend_ID = P.ID) AS sub ON S.ID = sub.ID
INNER JOIN Packages AS P ON S.ID = P.ID
WHERE P.Salary < sub.Salary
ORDER BY sub.Salary
'코딩테스트 > 해커랭크 SQL' 카테고리의 다른 글
[해커랭크/MySQL] 45. Symmetric Pairs (0) | 2023.04.14 |
---|---|
[해커랭크/MySQL] 43. Weather Observation Station 17 (0) | 2023.04.10 |
[해커랭크/MySQL] 42. Weather Observation Station 16 (0) | 2023.04.10 |
[해커랭크/MySQL] 41. Weather Observation Station 15 (0) | 2023.03.21 |
[해커랭크/MSSQL] 40. Ollivander's Inventory (0) | 2023.03.21 |
댓글