My best solution, super clean, no subquery, no Max
Oftentimes those interviewers won't allow you to write subquery~\n\nReturn the highest salary for each department\n\n      SELECT D.Name as Department, E.Name a
Oftentimes those interviewers won't allow you to write subquery~\n\n**Return the highest salary for each department**\n\n      SELECT D.Name as Department, E.Name as Employee, E.Salary \n      FROM Department D, Employee E, Employee E2  \n      WHERE D.ID = E.DepartmentId and E.DepartmentId = E2.DepartmentId and \n      E.Salary <= E2.Salary\n      group by D.ID,E.Name having count(distinct E2.Salary) = 1\n      order by D.Name desc\n\n**Follow up, return the secondary salary for each department**\n\n       SELECT D.Name as Department, E.Name as Employee, E.Salary \n       FROM Department D, Employee E, Employee E2  \n       WHERE D.ID = E.DepartmentId and E.DepartmentId = E2.DepartmentId and \n       E.Salary < E2.Salary\n       group by D.ID,E.Name having count(distinct E2.Salary) = 1\n       order by D.Name desc
[]