93% FASTER
\n\n\n\nSELECT Department, Employee, Salary \nFROM ( \n        SELECT *, rank() over(PARTITION BY Department ORDER BY Salary DESC) AS Highest_Salaries \n       
![image](https://assets.leetcode.com/users/images/5a4bea54-9e8e-4929-9709-77afb82be822_1668422497.2098377.png)\n\n\n```\nSELECT Department, Employee, Salary \nFROM ( \n        SELECT *, rank() over(PARTITION BY Department ORDER BY Salary DESC) AS Highest_Salaries \n        FROM (\n                SELECT d.name AS Department, e.name AS Employee, e.salary AS Salary\n                FROM Department d\n                INNER JOIN Employee e\n                ON d.id = e.departmentId\n            ) AS x         \n    ) AS y\nWHERE Highest_Salaries < 2;\n```
[]