Got an TLE with a simple way.


  • 0
    A
    select d.Name as Department, e.Name as Employee, e.Salary as Salary
    from Employee as e
    left join Department as d on e.DepartmentId = d.Id
    where e.Salary = (select max(Salary) from Employee e2 where e2.DepartmentId = d.Id)
    

    I used a quite straightforward way, but got a TLE with no idea why. I see in the discussion someone uses the same approach of mine and passed it!

    Any idea? Thanks!


  • 0
    H
    select d.Name Department, e.Name Employee, e.Salary Salary
    from Employee e
    join Department d on e.DepartmentId = d.Id
    where e.Salary = (select max(Salary) from Employee e2 where e2.DepartmentId = d.Id)
    order by e.salary desc

  • 0
    H

    for alias u don't need to write AS


Log in to reply
 

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