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
|
1901 Discussions
|
Please Login in order to post a comment
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
With friendsalary as ( select d.ID, d.Friend_ID, p.Salary from Friends d join Packages p on d.Friend_ID = p.ID ),
studentsalary as ( select s.ID,s.Name, p1.Salary from Students s join Packages p1 ON s.ID = p1.ID ) select ss.Name from studentsalary ss join friendsalary fs on ss.ID = fs.ID where ss.Salary < fs.Salary order by fs.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;
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;