select d.Name, e.Name, e.Salary from Department d, Employee e, (select MAX(Salary) as Salary, DepartmentId as DepartmentId from Employee GROUP BY DepartmentId) h where e.Salary = h.Salary and e.DepartmentId = h.DepartmentId and e.DepartmentId = d.Id;
What do you mean by no JOIN? the comma separated tables represents a CROSS JOIN, while in your case it will be an equivalent to INNER JOIN as you are using the WHERE clause:
Did I understand something wrong?
SELECT (SELECT Name FROM Department WHERE Id = E.DepartmentId) AS Department, E.Name AS Employee, E.Salary AS Salary FROM Employee AS E WHERE E.Salary >= ALL(SELECT Salary FROM Employee WHERE DepartmentId = E.DepartmentId) AND EXISTS (SELECT * FROM Department WHERE Id = E.DepartmentId);
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.