일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- stak
- PPMI
- Heap
- 신경망
- MySQL
- que
- SQL
- 프로그래머스
- CBOW
- backward
- hash
- 자연어처리
- algorithm
- 파이썬
- boj
- Word2vec
- select
- 딥러닝
- affine
- dl
- Sigmoid
- Python
- Numpy
- skip-gram
- Programmers
- kakao
- Stack
- DeepLearning
- sort
- FullyConnectedLayer
Archives
- Today
- Total
혜온의 이것저것
[HackerRank] Placements (MySQL) 본문
https://www.hackerrank.com/challenges/placements/problem?isFullScreen=true
문제
You are given three tables: Students, Friends and Packages. Students contains two columns: ID and Name. Friends contains two columns: ID and Friend_ID (ID of the ONLY best friend). Packages contains two columns: ID and Salary (offered salary in $ thousands per month).
Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be ordered by the salary amount offered to the best friends. It is guaranteed that no two students got same salary offer.
Sample Input
Sample Output
Samantha
Julia
Scarlet
Explanation
See the following table:
Now,
- Samantha's best friend got offered a higher salary than her at 11.55
- Julia's best friend got offered a higher salary than her at 12.12
- Scarlet's best friend got offered a higher salary than her at 15.2
- Ashley's best friend did NOT get offered a higher salary than her
The name output, when ordered by the salary offered to their friends, will be:
- Samantha
- Julia
- Scarlet
풀이
select s.name
from students s
join friends f on s.id=f.id
join packages p1 on s.id=p1.id
join packages p2 on f.friend_id=p2.id
where p1.salary<p2.salary
order by p2.salary
'Data Analysis > SQL' 카테고리의 다른 글
[HackerRank] Interviews (MySQL) (0) | 2022.09.23 |
---|---|
[HackerRank] Symmetric Paris (MySQL) (0) | 2022.09.22 |
[HackerRank] SQL Project Planning (MySQL) (0) | 2022.09.13 |
[HackerRank] Contest Leaderboard (MySQL) (0) | 2022.09.08 |
[HackerRank] Challenges (MySQL) (0) | 2022.09.08 |
Comments