• + 0 comments
    SELECT N FROM 
    (SELECT S1.Name as N, P1.Salary AS S1 ,P2.Salary AS S2 
    FROM Friends 
    JOIN Packages AS P1 ON Friends.ID=P1.ID 
    JOIN Packages AS P2 ON Friends.Friend_ID=P2.ID 
    JOIN Students AS S1 ON S1.ID=Friends.ID) 
    WHERE S2>S1 
    ORDER BY S2 ASC;