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 CTE as
(select s.id, s.name, p.salary as salary, f.friend_ID, p2.salary as salary_2
from Students s join friends f on f.id=s.id
join Packages p on p.ID= s.id join packages p2 on f.Friend_ID = p2.id)
select name from CTE
where salary_2>salary
order by salary_2;
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 CTE as (select s.id, s.name, p.salary as salary, f.friend_ID, p2.salary as salary_2 from Students s join friends f on f.id=s.id join Packages p on p.ID= s.id join packages p2 on f.Friend_ID = p2.id) select name from CTE where salary_2>salary order by salary_2;