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.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.