• + 0 comments

    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 ;