Why my solution in wrong, I can run it successfully on my local environment


  • 0
    D
    select d.Name as Department, e.Employee, e.Salary                                                                  
    from Department d
    inner join
    (
      select Name as Employee, DepartmentId, Salary 
      from Employee,
      (select max(Salary) as max_salary from Employee group by DepartmentId) as s where Salary=s.max_salary
    )  as e on d.id=e.DepartmentId;

  • 0
    L

    (select max(Salary) as max_salary from Employee group by DepartmentId)

    the execute order is from -> group by -> select, and function max() is in "select" space, so max() is not execute in your mind.

    (My English is not good)


Log in to reply
 

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