Sort by

recency

|

1759 Discussions

|

  • + 0 comments

    select s.name from students s join friends f on s.id = f.id join ( select salary, id from packages where id in (select friend_id from friends) ) f_sal on f_sal.id = f.Friend_ID join packages p on s.id = p.id where f_sal.salary > p.salary order by f_sal.salary ;

  • + 0 comments

    with CTE as (select s.id, s.name, p.salary as salary, f.friend_ID, p2.salary as salary_2 from Students s join friends f on f.id=s.id join Packages p on p.ID= s.id join packages p2 on f.Friend_ID = p2.id) select name from CTE where salary_2>salary order by salary_2;

  • + 0 comments

    My SQL solution select name from students s join friends f on s.id=f.id join packages p on f.id=p.id join packages p1 on f.friend_id=p1.id where p.salary

  • + 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;
    
  • + 0 comments

    select s.name from friends f join packages p1 on f.friend_ID=p1.ID join packages p2 on f.ID=p2.ID join students s on s.id=f.id where p1.salary>p2.salary order by p1.salary