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 required_table
as ( select s.id,s.name,friend_id as bf,salary from students s
join friends f on s.id = f.id
join packages p on s.id = p.id )
select t1.name from required_table t1
join required_table t2 on t1.bf = t2.id
where t2.salary > t1.salary
order by t2.salary
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 required_table as ( select s.id,s.name,friend_id as bf,salary from students s join friends f on s.id = f.id join packages p on s.id = p.id ) select t1.name from required_table t1 join required_table t2 on t1.bf = t2.id where t2.salary > t1.salary order by t2.salary