Don't take the test too seriously

  • 1

    select d.Name as Department, e.Name as Employee, e.Salary
    from Employee e, Employee e2, Department d
    where e.DepartmentId = e2.DepartmentId
    and e.Salary <= e2.Salary
    and e.DepartmentId = d.Id
    group by e.Id, e.Name, e.Salary, e.DepartmentId, d.Name
    having count(*) <=3
    order by e.DepartmentId, e.Salary desc;

    The above is definitely a correct answer and works on MySQL. It should also work for Oracle as well. I tried to use standard SQL only.

    It works fine in my database. But when I submit, I got 'Wrong Answer'
    I figured out some of tests cases try to test top 4, some tried to test top 3. So it will not satisfy all cases.

Log in to reply

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