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.
SELECT NAME
FROM(
SELECT st.id,st.name,p1.salary as my_sal,
p2.salary as frnd_sal
from students as st join friends on st.id = friends.id join packages
as p1 on st.id = p1.id join packages
as p2 on friends.friend_id = p2.id
)
WHERE frnd_sal > my_sal
ORDER BY frnd_sal;
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 →
SELECT NAME FROM( SELECT st.id,st.name,p1.salary as my_sal, p2.salary as frnd_sal from students as st join friends on st.id = friends.id join packages as p1 on st.id = p1.id join packages as p2 on friends.friend_id = p2.id ) WHERE frnd_sal > my_sal ORDER BY frnd_sal;