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
|
1825 Discussions
|
Please Login in order to post a comment
SELECT Stu_Name FROM (SELECT s.ID as Stu_ID,s.Name as Stu_Name,p.Salary as Stu_Sal,f.Friend_ID as FriendID from Students s left join Friends f on f.ID = s.ID left join Packages p on p.ID = s.ID) as CTE left join Packages c on c.ID = CTE.FriendID where c.Salary > Stu_Sal order by c.Salary;
WITH t as( SELECT S.ID AS ID, S.Name AS Name, P.Salary AS Salary, (SELECT Salary FROM Packages WHERE ID = F.Friend_ID) AS Friend_Salary FROM Students S JOIN Friends F ON S.ID = F.ID JOIN Packages P ON F.ID = P.ID
) SELECT Name From t WHERE Friend_Salary > Salary ORDER BY Friend_Salary ASC
select s.name from friends f join packages p on p.id=f.id join packages p2 on p2.id=f.friend_id join students s on s.id = p.id where p.salary < p2.salary order by p2.salary
select s.Name from students s inner join Friends f on s.ID=f.ID inner join Packages sp on s.ID=sp.ID inner join Packages fp on f.Friend_ID=fp.ID where fp.salary>sp.salary order by fp.salary