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
|
1899 Discussions
|
Please Login in order to post a comment
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;
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;
with friend_sal as ( select f.id,f.friend_id,p.salary from friends f join packages p on f.friend_id = p.id
),stud_sal as ( select s.id,s.name,p1.salary from students s join packages p1
on s.id = p1.id ) select ss.name from stud_sal ss join friend_sal fs ON ss.id = fs.id where fs.salary > ss.salary order by fs.salary