Clear simple solution, beat 90%


  • 1
    X
    SELECT D.Name as Department, E1.Name as Employee, E1.Salary
    FROM Employee E1
    INNER JOIN Employee E2 ON E1.DepartmentId = E2.DepartmentId
    INNER JOIN Department D ON E1.DepartmentId = D.Id
    WHERE E1.Salary <= E2.Salary
    GROUP BY E1.Id
    HAVING count(DISTINCT E2.Salary) < 4;
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.