Placements — HackerRank Advanced SQL (cool)

Samantha
Julia
Scarlet
  • Julia’s best friend got offered a higher salary than her at 12.12
  • Scarlet’s best friend got offered a higher salary than her at 15.2
  • Ashley’s best friend did NOT get offered a higher salary than her
  • Julia
  • Scarlet
SELECT NAME
FROM (SELECT s.id,
NAME,
salary
FROM students s
INNER JOIN packages p
ON ( s.id = p.id )
) a
INNER JOIN
(SELECT f.id,
friend_id,
salary AS friend_salary
FROM friends f
INNER JOIN packages p
ON ( f.friend_id = p.id )
) b
ON ( a.id = b.id )
WHERE friend_salary > salary
ORDER BY friend_salary;
Stuart 
Priyanka
Paige
Jane
Julia
Belvet
Amina
Kristeen
Scarlet
Priya
Meera

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store