Why this doesn't Work?

  • 0

    SELECT D.Name AS Department, E.Name AS Employee, E.Salary AS Salary FROM
    (SELECT Id, Name, Salary, DepartmentId FROM Employee GROUP BY DepartmentId ORDER BY Salary DESC LIMIT 3) E, Department D WHERE D.Id = E.DepartmentId

  • 0

    When you use GROUP BY, you have to use one of the aggregate functions, which is missing in your code. LIMIT 3 is NOT the aggregate function.

Log in to reply

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