You can also create a general solution for this top X problem


  • 0
    J

    SELECT D.Name Department, E.Name Employee, E.Salary Salary
    FROM
    Employee E,
    Department D
    WHERE E.DepartmentId = D.Id
    AND
    (SELECT COUNT(DISTINCT Salary) FROM Employee WHERE E.Salary < Salary AND E.DepartmentId = DepartmentId) < 1


Log in to reply
 

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