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
|
1777 Discussions
|
Please Login in order to post a comment
;WITH SalryCTE AS (
select S.id, S.friend_id, SP.salary AS Salary, FP.Salary AS friendsalary FROM Friends S left join Packages SP ON S.id=SP.id left join Packages FP ON S.friend_id=FP.id ) SELECT S.Name FROM Students S join SalryCTE SC ON S.id=SC.id where SC.friendsalary>SC.Salary order by SC.friendsalary;
with cte1 as( SELECT s.id as id, s.name as name, p.salary as salary, f.friend_id as friend_id FROM Students s JOIN Friends f ON s.id = f.id JOIN packages p ON s.id = p.id) SELECT c1.name as main_name FROM cte1 c1 JOIN students s1 ON c1.friend_id = s1.id JOIN packages p2 ON p2.id = s1.id WHERE p2.salary > c1.salary ORDER BY p2.salary;
with cte as ( select a.ID as ID, a.Name as Name, c.Salary as Salary, b.Friend_ID as Friend_ID, d.Salary as Friend_Salary FROM Students a join Friends b on a. ID = b.ID join Packages c on b.ID=c.ID join Packages d on b.Friend_ID =d.Id )
SELECT Name from cte where Friend_Salary > Salary order by Friend_Salary