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).



  1. SELECT S.NAME
  2. FROM STUDENTS S,
  3. FRIENDS F,
  4. PACKAGES P1,
  5. PACKAGES P2
  6. WHERE S.ID = F.ID
  7. AND F.FRIEND_ID = P2.ID
  8. AND S.ID = P1.ID
  9. AND P1.SALARY < P2.SALARY
  10. ORDER BY P2.SALARY;




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube