SQL: Department Top Earner
Medium
SQL — Window Functions
SQL
RANK
PARTITION BY
Find highest salary in each department.
Constraints
Write standard SQL (MySQL 8.0 compatible).
Examples
Example 1:
Input: dept salary
IT 15000
IT 18000
HR 12000
Output:
Example 2:
Input: dept salary
IT 15000
IT 18000
HR 12000
Output:
Hints
Window function or GROUP BY.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console