leetcode

Leetcode submissions
git clone git://git.laack.co/leetcode.git
Log | Files | Refs | README

department-highest-salary.sql (356B)


      1 --Find the highest salary based on
      2 --department returning multiple if there
      3 --are people with the same salary.
      4 SELECT d.name AS Department, e.name AS Employee, e.Salary
      5 FROM Employee e
      6 INNER JOIN Department d ON e.departmentId = d.id
      7 WHERE (e.departmentId, e.salary) IN (
      8     SELECT departmentId, MAX(salary)
      9     FROM Employee
     10     GROUP BY departmentId
     11 );