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
|
1619 Discussions
|
Please Login in order to post a comment
SELECT S.Name --, S1.Name as FriendName,P.Salary,P1.Salary as FriendSalary FROM Friends F LEFT JOIN Students S ON F.Id = S.Id LEFT JOIN Students S1 ON F.friend_ID = S1.Id LEFT JOIN Packages P ON P.Id = F.Id LEFT JOIN Packages P1 ON P1.Id = F.friend_ID WHERE P1.Salary>P.Salary Order by P1.Salary
V E R Y E A S Y S O L U T I O N
SELECT s.Name FROM Students s JOIN Friends f ON s.ID = f.ID JOIN Packages p_self ON s.ID = p_self.ID JOIN Packages p_friend ON f.Friend_ID = p_friend.ID WHERE p_friend.Salary > p_self.Salary ORDER BY p_friend.Salary;
select a.name from students a left join( select b.id, b.friend_id, c.salary from friends b left join packages c on b.friend_id = c.id ) e on a.id = e.id left join packages d on a.id = d.id where e.salary > d.salary order By e.salary
select 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 p1.Salary
Check out the complete video solution here - https://www.youtube.com/watch?v=gw7ceFdKkpQ&t=22s