Rank() over (partition ... Does not work


  • 0
    E

    Below should be the correct way to do this in reality, but this site doesn't seem to support analytic functions.

    SELECT * FROM 
       (SELECT d.name as Department, e.name as Employee, 
       rank() over (partition by d.name ORDER BY Salary DESC) as Salary_Rank
       FROM Employee e 
       INNER JOIN Department d on e.Id = d.Id) main
    WHERE Salary_Rank < 4

  • 0
    J

    MySQL doesn't support rank_over


  • 0
    F

    "INNER JOIN Department d on e.Id = d.Id" shoud be "INNER JOIN Department d on e.DepartmentId = d.Id"


Log in to reply
 

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