select d.Name, r.Name, r.Salary from ( select DepartmentId, Name, Salary,( select count(*)+1 from ( select distinct salary, DepartmentId from Employee ) as uniq where DepartmentId = e.DepartmentId and Salary > e.Salary ) as rank from Employee e ) as r, Department d where r.DepartmentId = d.Id and r.rank <= 3
select Department, Employee, Salary
(Select Employee, Department, Salary, Rank() Over (Partition by Department order by Salary desc) AS E_Rank
(select A.Name AS Employee, B.Name AS Department, Salary
From Employee A INNER JOIN Department B
This code works fine in MySQL in my laptop but not in leetcode. in leetcode throws a runtime exception.