HackerRank MySQL - Placements
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).
- SELECT S.NAME
- FROM STUDENTS S,
- FRIENDS F,
- PACKAGES P1,
- PACKAGES P2
- WHERE S.ID = F.ID
- AND F.FRIEND_ID = P2.ID
- AND S.ID = P1.ID
- AND P1.SALARY < P2.SALARY
- ORDER BY P2.SALARY;