Skip to content

Practice Department Highest Salary

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#184
LeetCode Problem

Department Highest Salary

Problem Statement

Tables: Employee(id INT, name VARCHAR, salary INT, departmentId INT); Department(id INT, name VARCHAR). Employee.id and Department.id are unique keys. Employee.departmentId references Department.id; department names are non-null. Return Department, Employee and Salary for all employees earning the maximum salary within their department. Include every employee tied at that maximum. Output order is unrestricted.

Source: Department Highest Salary on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
Employee table: +----+-------+--------+--------------+ | id | name  | salary | departmentId | +----+-------+--------+--------------+ | 1  | Joe   | 70000  | 1            | | 2  | Jim   | 90000  | 1            | | 3  | Henry | 80000  | 2            | | 4  | Sam   | 60000  | 2            | | 5  | Max   | 90000  | 1            | +----+-------+--------+--------------+ Department table: +----+-------+ | id | name  | +----+-------+ | 1  | IT    | | 2  | Sales | +----+-------+
Output
+------------+----------+--------+ | Department | Employee | Salary | +------------+----------+--------+ | IT         | Jim      | 90000  | | Sales      | Henry    | 80000  | | IT         | Max      | 90000  | +------------+----------+--------+

Related LeetCode Problems

Practice more problems similar to Department Highest Salary.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.