Sort by

recency

|

1788 Discussions

|

  • + 0 comments

    With Cte As ( Select S.ID,S.Name,P.Salary From Students As S Join Packages As P On S.ID = P.ID ) , CteFriend As ( Select C.* ,F.Friend_ID From Cte As C Join Friends As F On C.ID = F.ID

    ) Select Name from CteFriend As Cf Join Packages As P On Cf.Friend_ID = P.ID Where Cf.Salary < P.Salary Order by p.Salary

  • + 0 comments

    WITH cte AS( SELECT S.ID AS student_id, S.Name AS student_name, f.friend_id AS friend_id, ps.salary AS student_salary, ps.id AS s_id, pf.salary AS friend_salary, pf.id AS f_id FROM Students S JOIN Friends f ON S.ID = F.ID JOIN Packages ps ON ps.id = s.id JOIN Packages pf ON pf.id = f.friend_id order by 1) SELECT student_name FROM cte WHERE friend_salary > student_salary order by friend_salary

  • + 0 comments

    WITH OwnSalaryTable AS ( SELECT f.ID, f.Friend_ID, p.Salary AS "My_salary" FROM Friends f JOIN Packages p ON f.ID = p.ID ), TotalSalaryTable AS ( SELECT ost.ID, ost.Friend_ID, ost.My_salary, p.Salary AS "Friend_salary" FROM OwnSalaryTable ost JOIN Packages p ON ost.Friend_ID = p.ID ) SELECT s.Name FROM Students s JOIN TotalSalaryTable tst ON s.ID = tst.ID WHERE tst.My_salary < tst.Friend_salary ORDER BY tst.Friend_salary

  • + 0 comments

    MS SQL SERVER

    With CTE AS

    (

    Select s.Id as SID , Name, f.Friend_ID AS FID, Salary
    
    from Students s
    
    inner join Friends f on s.Id = F.Id
    
    inner join Packages p on f.ID = p.ID
    

    )

    Select b.name from CTE a

    inner join CTE b on a.SID = b.FID where a.Salary > b.Salary order by a.Salary

  • + 0 comments

    With cte as(

    select f.id,f.friend_id,s.name,p.Salary from friends as f Left join students as s on f.id=s.id Left join Packages as p on f.id=p.id ), cte2 as( select distinct c1.salary,c2.name from cte as c1 join cte as c2 on c1.id=c2.friend_id where c1.salary>c2.salary

    )

    select name from cte2 order by salary asc