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.
with t as
(select stu.id as ID, stu.name as Name , pak.salary as Salary , frnd.friend_id as FriendId from students as stu , friends as frnd , packages as pak where stu.id = pak.id and frnd.id = pak.id
),
s as
(
select t1.ID as tid , t1.Name as Names , t1.Salary as firstsal , t1.FriendId , t2.Salary as secondsal from t as t1 , t as t2 where t1.FriendId = t2.ID
)
select Names from s where firstsal < secondsal order by secondsal;
Placements
You are viewing a single comment's thread. Return to all comments →
In MS SQL
with t as (select stu.id as ID, stu.name as Name , pak.salary as Salary , frnd.friend_id as FriendId from students as stu , friends as frnd , packages as pak where stu.id = pak.id and frnd.id = pak.id ),
s as ( select t1.ID as tid , t1.Name as Names , t1.Salary as firstsal , t1.FriendId , t2.Salary as secondsal from t as t1 , t as t2 where t1.FriendId = t2.ID )
select Names from s where firstsal < secondsal order by secondsal;