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.
- Prepare
- SQL
- Advanced Join
- Placements
- Discussions
Placements
Placements
Sort by
recency
|
1890 Discussions
|
Please Login in order to post a comment
SELECT Students.Name FROM ( SELECT Friends.ID, Friends.Friend_ID, Packages.Salary as Friend_Salary FROM Friends JOIN Packages ON Packages.ID = Friends.Friend_ID) as a JOIN Students ON a.ID = Students.ID JOIN Packages ON a.ID = Packages.ID WHERE a.Friend_Salary > Packages.Salary ORDER BY a.Friend_Salary ASC;
with friend_salary as ( select p.salary, f.id from packages as p inner join friends as f on p.id = f.friend_id)
SELECT s.name from students as s inner join friend_salary as f on s.id = f.id inner join packages as p on s.id = p.id where p.salary < f.salary order by f.salary;
SELECT s.Name FROM Students s JOIN Friends f ON s.ID = f.ID JOIN Packages p1 ON s.ID = p1.ID JOIN Packages p2 ON f.Friend_ID = p2.ID WHERE p2.Salary > p1.Salary ORDER BY p2.Salary;