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 chk.name
FROM packages p INNER JOIN
(
SELECT s.id, s.name as name, f.friend_id as friend_id,
p.salary as my_salary from
friends f INNER JOIN students s ON s.id = f.id
INNER JOIN packages p ON f.id = p.id
) as chk
ON chk.friend_id = p.id
and chk.my_salary < p.salary
order by p.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 →
In MYSQL
SELECT chk.name FROM packages p INNER JOIN ( SELECT s.id, s.name as name, f.friend_id as friend_id, p.salary as my_salary from friends f INNER JOIN students s ON s.id = f.id INNER JOIN packages p ON f.id = p.id
) as chk ON chk.friend_id = p.id and chk.my_salary < p.salary order by p.salary;