We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
with all_friends as (SELECT s.Name,
f.ID,
f.Friend_ID,
p.Salary AS person_salary,
pg.Salary AS friend_salary
FROM Students s
INNER JOIN Friends f ON s.ID = f.ID
INNER JOIN Packages p ON s.ID = p.ID
INNER JOIN Packages pg ON f.Friend_ID = pg.ID
friend's salary
WHERE pg.Salary > p.Salary
ORDER BY pg.Salary ASC)
SELECT Name FROM all_friends;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Placements
You are viewing a single comment's thread. Return to all comments →
with all_friends as (SELECT s.Name, f.ID, f.Friend_ID, p.Salary AS person_salary, pg.Salary AS friend_salary FROM Students s INNER JOIN Friends f ON s.ID = f.ID INNER JOIN Packages p ON s.ID = p.ID INNER JOIN Packages pg ON f.Friend_ID = pg.ID friend's salary WHERE pg.Salary > p.Salary ORDER BY pg.Salary ASC) SELECT Name FROM all_friends;